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

exec with awk script

Status
Not open for further replies.

jaytco

Vendor
Dec 13, 2001
88
US
I have an expect script and I would like to issue the following with exec. I have escaped the ', {, }, ", $0, ; all with no luck. The following works from command line.
Code:
awk '{print substr($0,2,3) "," substr($0,5,3) "," substr ($0,8);}' ${host}.${date}.vlr > ${host}.${date}.vlr.csv
$0 - Internal variable to awk
$host, $date - expect defined variables.

I get the following error - (With escape chars in place)
Code:
awk: syntax error near line 1
awk: bailing out near line 1
    while executing
"exec awk '\{print substr(\$0,2,3) "," substr(\$0,5,3) "," substr (\$0,8)\;\}' ${host}.${date}.vlr > ${host}.${date}.vlr.csv"
 
This is really an (g)awk question. Embedding command instructions for other interpreters in expect/tcl is really
the least valuable solution IMHO. If you ever looked at the
old xconfig script for the linux kernel you have an idea why. While very nimble technical coding it introduced more serious issues than it solved.

My suggestion is figure out a way to extract the info you
need more succinctly and within the parameters of tcl/expect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top