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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to protect () chars returned from a cursor

Status
Not open for further replies.

ixnay5

MIS
Jan 10, 2002
68
0
0
US
Hi all...

I have a 4gl program which puts a value returned from a cursor in to an echo command string variable. When the string is "run", the value of "reg.home_phone" is supposed to be written into a text file. This code plays well other records, but there's a problem using it with this particular record. Here we go:

----------
let emailmessage6 = "echo ",reg.home_phone," >> /hr/addresschangetemp.txt"
run emailmessage6
----------

The problem is, the value returned in reg.home_phone is a phone number formatted like this: (909)555-9999. Looks like bash doesn't like the () chars because I get this error:

----------
bash: -c: line 1: syntax error near unexpected token '(909)'
bash: -c: line 1: `echo (909)555-9999 ' >> /hr/addresschangetemp.txt
----------

How can I protect the () chars? Also, there's no guarantee () will appear in every reg.home_phone record.

Thanks!!!

ixnay5

 
Try this

let emailmessage6 = "echo '",reg.home_phone,"' >> /hr/addresschangetemp.txt"

that is singel quotation mark around reg.home_phone so that the echo line looks like this

echo '(909)555-9999' >> /hr/addresschangetemp.txt

The single quotation mark indicates to the echo command the this is an argument

Thorkild
 
hey Thorkild...THANKS! Your suggestion worked!!

ixnay5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top