"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


|