Hi can any one let me know if awk doesnt work with the coprocess??? I have tried a simple example mentioned below but couldnt get it working seems like awk doesnt work with the coprocess concept. I would appreciate very much for any inputs on this.
awk does not work as a coprocess for me. It hangs when I try to read a result and it probably is buffering the input. But you are redirecting the output of the coprocess back to standard-in anyway. I don't understand what you're trying to do with that script. Here is a script that uses a bc coprocess to add numbers (which works) and tries to uses an awk coprocess to add numbers (which hangs).
Well, I was trying to exchange the values between the standard-input and the awk. so, is there a way to find which are all the list of commands that work as a co process??? Wouldn't it be possible to have the coprocess within awk??
Only way is to try the command and see. There aren't that many commands that would be useful as coprocesses. I regularly use adb, bc, ftp, and telnet. These are commands that were intended to be used interactively... a strong clue that they are candidates for a coprocess.
Haven't logged in for a while and I stumbled on this post.
I could never get awk to work as a coprocessor either. I was mentoring a coworker on coprocessors and while he was testing the fundamentals, I noticed that he wrapped awk in a shell script something like this:
Script cp.sh
#! /usr/bin/ksh -p
while :
do
read LINE
[[ "$LINE" = "QUIT" ]] && break
print - "$LINE" | nawk '{
if ( $0 ~ /^[0-9][0-9][0-9]/ ) {
print "1"
} else {
print "0"
}
}'
done