Quote:
Originally Posted by
radoulov
hey man, you seemed not to get what I was trying to do. So after I analyze the data, I need to prompt to users what to do next. So in my awk script I use
getline < "-" (or
getline "/dev/stdin"). It works fine for file processing but fails for pipe.
The problem can be triggered easily, e.g.
gawk ' BEGIN {
printf "Enter your name:"
getline name < "-"
}
{print name} ' somefiles works just fine.
But it fails when
cat somefiles | gawk ' BEGIN {
printf "Enter your name:"
getline name < "-"
}
{print name} '
So my question is how to make it work for pipe (putting in BEGIN block won't work either)? Of course I can make this user interaction part in shell script, but it will make my awk script more awkward, so I want do it in awk script.
BTW I use gawk 3.1.6 and try solaris nawk, they both fails for pipe