[SLL] Simple Bash execution of string: How do I execute the string?
Xeno Campanoli
xcampanoli at gmail.com
Tue Jun 10 16:57:45 PDT 2008
Steve McCarthy wrote:
> My vote:
>
> eval $x
>
Yes, eval $x seems to work fine. Thanks to everyone.
Sincerely, Xeno
>
> On Tue, Jun 10, 2008 at 3:50 PM, Bill Campbell <bill at celestial.com> wrote:
>
>> On Tue, Jun 10, 2008, Xeno Campanoli wrote:
>>> I've got a simple call:
>>>
>>> curl -L -i -H 'Content-Type: text/html; charset=utf-8' host
>>>
>>> which works great, but when I go:
>>>
>>> x="curl -L -i -H 'Content-Type: text/html; charset=utf-8' host"
>>>
>>> (and I can check it, and it looks the same as the one that works when I
>>> go echo $x) then doing:
>>>
>>> `$x` is not working for me. It is getting the parts of the header
>>> string as separate arguments:
>>>
>>> curl: (6) Couldn't resolve host 'text'
>>>
>> You are running into problems with whitespace in the command which needs to
>> be escaped. It is splitting the -H argument into pieces.
>>
>> I think you would get something if you executed it in the command, setting
>> x to the output of the command, but I don't think this would do you much
>> good here.
>>
>> x=`curl -L -i -H 'Content-Type: text/html; charset=utf-8' host`
>>
>> Bill
>> --
>> INTERNET: bill at celestial.com Bill Campbell; Celestial Software LLC
>> URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
>> Voice: (206) 236-1676 Mercer Island, WA 98040-0820
>> Fax: (206) 232-9186
>>
>> The children who know how to think for themselves spoil the harmony of
>> the collective society that is coming, where everyone would be
>> interdependent. 1899 John Dewey, educational philosopher, proponent of
>> modern public schools.
>>
>
>
>
More information about the linux-list
mailing list