hello everyone,
I am able to go further with getline from exact terminal device.
From my UNIX prompt, my terminal device is /dev/pts/26.
$ > tty
/dev/pts/26
$ >
So, I changed the getline command as below:
tail -f log.file |nawk '
{print $0}
$0 ~ /error/ {
print "Error found. Press ENTER to acknowledge."
getline i <
"/dev/pts/26"
}
$0 ~ /aborted/ {
print "Error found. Press ENTER to acknowledge."
getline i < "-"
}
'
It paused and wait for acknowledgement. But ...
How can I get current terminal device into my nawk? each time I log in, I will get diff. terminal device.
I tried the following but all fail:
=1= Begin stmt
BEGIN {dev = ENVIRON["$devID"]}
. . .
getline i < "$dev"
note: I export tty value prior nawk stmt (export devID=`tty`)
=2= and ...
getline i < system ("echo $devID")
getline i < system ("echo `tty`")
getline i < "ENVIRON["$devID"]"
None of them seem to work for me.
when I tried the command below,
getline i < "/dev/tty"
It works most of the time.
Once in a while, it failed too.
Please help.
Thanks
George