Operating System - HP-UX
1834150 Members
2457 Online
110064 Solutions
New Discussion

expect script syntax problem

 
William Harris_3
Occasional Contributor

expect script syntax problem

can someone help me find the correct syntax to the following? i'm trying to loop through the output of awk command.

foreach line [ awk '$4 == 103 && $9 !="*.rec" { print $9 }' incomingfiles.rec ].

thanks in advance,

chris
4 REPLIES 4
S.K. Chan
Honored Contributor

Re: expect script syntax problem

What about ..
..
awk '$4==103 && $9 !="*.rec" {print $9}' incomingfiles.rec | while read LINE
do
print $LINE
done
...
S.K. Chan
Honored Contributor

Re: expect script syntax problem

I'm sorry I did not read well.. you said "Expect script" .. ignore my post.
curt larson_1
Honored Contributor

Re: expect script syntax problem

well it has been awhile and i don't have an expect installation for testing, but something like this should get you started.

your probably going to have to play with the quoting for the awk statement.

set input [open "| awk '$4 == 103 && $9 != \"*.rec\" {print $9;}' infile.rec " ]

while {[gets $input line] != -1} {
#do something with $line
puts "$line"
}
close $input
John Meissner
Esteemed Contributor

Re: expect script syntax problem

expect isn't really the problem here I would think... as suggested ... it's probably just your line or quoting...

you could try it like this
cat file |
while read line
do
echo $line | awk '$4 == 103 && $9 !="*.rec" { print $9 }' incomingfiles.rec
done
All paths lead to destiny