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 6 of 8 Topic 2220 of 2297
Post > Topic >>

Re: Bypassing variable substitution

by pk <pk@[EMAIL PROTECTED] > Apr 12, 2008 at 01:04 PM

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.

-- 
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
 




 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 Sun Jul 6 20:40:29 CDT 2008.