Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignoring "(" in a variable when used in a system call.

Status
Not open for further replies.

gawker

Programmer
Feb 21, 2002
34
US
Hi,

In a awk process, I am reading data from a file where some of the data lines contain text bracketed by parenthesis like the following example:

...SysKonnect PCI FDDI Adapter (48110040)

I set up a variable:

Adapter_Desc = substr($0,30,length($0))

And then try to echo the data via a system call:

system("echo Adapters........: "$1 Adapter_Fill " - " Adapter_Desc)

The system/echo generates errors for each of the lines with the "()" text format:

sh: 0403-057 Syntax error at line 1 : `(' is not expected.

If I only extract 5 bytes starting at 30, it works fine.

How do I code to ignore the "(" and ")"?

Regards,

gawker [trooper]

 
Just curious: any particular reason you use 'system(echo...)' OVER 'print/printf'? Looks _really_ odd to me......
 
Try putting a \ in front of the ( and the ) as in the following (untested) code.
Code:
gsub(/(/,"\\(",Adapter_Desc)
gsub(/)/,"\\)",Adapter_Desc)
Hope this helps. CaKiwi
 
vgesh99,

I decided to place the data into a file instead of stdout.

As far as why I went that path... good question. Perhaps it was because it was 2 a.m. when I coded that section [dazed] and got hung up on working with the problem rather then using a better method.

Either way, I'm not using the system/echo now.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top