Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Bypassing v...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 8 Topic 2220 of 2317
Post > Topic >>

Re: Bypassing variable substitution

by spcecdt@[EMAIL PROTECTED] (John DuBois) Apr 12, 2008 at 01:50 PM

In article <4800ac37$0$90263$14726298@[EMAIL PROTECTED]
>,
Rajan <svrajan@[EMAIL PROTECTED]
> wrote:
>
>
>"pk" <pk@[EMAIL PROTECTED]
> wrote in message news:ftq3sm$2pv$1@[EMAIL PROTECTED]
>> Rajan wrote:
>>
>>> This does work. If the string has as string has something like $item 
>>> shell
>>> is trying to expand it. Since I am double quoting it. If I single
quote
>>> it, the single quotes inside of the string are causing a problem.
>>
>> $ ex****t var="value"
>> $ awk 'BEGIN {system("echo \"$var\"")}'
>> value
>> $ awk -v sq="'" 'BEGIN {system("echo "sq"$var"sq)}'
>> $var
>>
>> Where are you getting errors? Post some example.
>>
>>> Let us make this more simple and generic.  The question is can I run a
>>> command with arguments containing $HOME , single quote and *s without
a
>>> lot of hopping in and out of  quotes. Something like the system in
perl
>>> (http://perldoc.perl.org/functions/system.html)
which when multiple
>>> arguments are passed sends all the strings as is to the first element
>>> without passing them through the shell?  To be more generic, does
system
>>> command always pass the command through the shell or is there a way
the
>>> command can be invoked directly without shell looking at its
arguments?
>>> Any information would help.
>>
>> AFAIK system() should invoke sh -c <command>, so the shell interprets
the
>> arguments.
>
>This is exactly what I wanted to know. Thanks, this helps.

Note that it's not too difficult to automatically quote arguments so that
they
won't be altered by the shell.  See for example
ftp://ftp.armory.com/pub/lib/awk/QuoteArgs

	John
-- 
John DuBois  spcecdt@[EMAIL PROTECTED]
  KC6QKZ/AE 
http://www.armory.com/~spcecdt/
 




 8 Posts in Topic:
Bypassing variable substitution
"Rajan" <svr  2008-04-11 22:16:05 
Re: Bypassing variable substitution
Ed Morton <morton@[EMA  2008-04-11 21:39:59 
Re: Bypassing variable substitution
"Rajan" <svr  2008-04-11 23:12:35 
Re: Bypassing variable substitution
Ed Morton <morton@[EMA  2008-04-11 22:27:10 
Re: Bypassing variable substitution
"Rajan" <svr  2008-04-12 00:39:26 
Re: Bypassing variable substitution
pk <pk@[EMAIL PROTECTE  2008-04-12 13:04:49 
Re: Bypassing variable substitution
"Rajan" <svr  2008-04-12 08:33:37 
Re: Bypassing variable substitution
spcecdt@[EMAIL PROTECTED]  2008-04-12 13:50:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 2:30:13 CDT 2008.