Files
hpr_website/www/eps/hpr3413/hpr3413_coproc_test.awk

28 lines
507 B
Awk
Executable File

#!/usr/bin/awk -f
BEGIN {
# Turn off buffering with bash
coproc = "stdbuf -i0 -o0 -e0 bash"
i = 0
# Commands we'll send
com[i++] = "date"
com[i++] = "whoami"
com[i++] = "id"
com[i++] = "exit"
i = 0
# Write and read in a loop → buffering problems?
do {
print com[i++] |& coproc
coproc |& getline results
if (i in com) print ":", results
} while (i in com)
close(coproc)
}
# vim: syntax=awk:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21