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 3 of 8 Topic 2220 of 2317
Post > Topic >>

Re: Bypassing variable substitution

by "Rajan" <svrajan@[EMAIL PROTECTED] > Apr 11, 2008 at 11:12 PM

"Ed Morton" <morton@[EMAIL PROTECTED]
> wrote in message 
news:480020FF.1020403@[EMAIL PROTECTED]
>
>
> On 4/11/2008 9:16 PM, Rajan wrote:
>> I have an application which interacts with the user using a command
line
>> program. I get files which have some information that needs to be
parsed 
>> and
>> then be sent as commands to my application. The output is then
processed
>> again using some gawk. Now the problem is my application's command has 
>> some
>> patterns which look like shell variables, regular expressions and shell
>> regular expressions. If I run this from gawk's system it p***** through

>> the
>> shell and shell tries to expand them which makes the commands appear 
>> weird
>> to my application.
>>
>> sample text from input file
>>
>> itemID,B9746
>> orderID,97733
>> itemID,A7632
>> itemID,B3328
>>
>> the commands look like
>>
>> my_command_parsing_prog list all itemID itemName qty -when $(itemID)
like
>> 'B9746.*'
>> my_command_parsing_prog list top 10 orderID salesCenter 
>> supplyCenter -when
>> $(orderID) match '^97733.*' -sort byMatch
>>
>> When I try to say system <one of above command> the *s and $s are 
>> expanded
>> by shell. Is there a way to run the command without passing them
through 
>> the
>> shell?
>>
>> Rajan
>>
>
> Maybe we can simplify the problem description. I think you want to do 
> this:
>
> $ ls
> a  b
> $ awk 'BEGIN{system("echo *")}'
> a b
> $ awk -v q=\' 'BEGIN{system("echo " q "*" q)}'
> *
>
> i.e. stop the wildcards in the string you pass to system() from being 
> expanded
> by the shell. If so, just quote them as above.
>
> Ed.
>

Thanks, but as you see the commands have single quotes in them so 
system("echo \" * \"") should work. This gives me the other problem
variable 
substitution. Is there a way we can pass a string with single quotes and 
things that look like shell variables / expressions to another program 
without going through the shell?

Rajan
 




 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 Thu Jul 24 15:12:04 CDT 2008.