![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| the shell not pause when execute read command | neruppu | Shell Programming and Scripting | 14 | 07-06-2008 07:34 PM |
| pause needed for corn shell | dennysavard | UNIX for Dummies Questions & Answers | 7 | 12-09-2007 02:16 PM |
| pause? where art thou? | 01000101 | High Level Programming | 3 | 05-15-2006 07:42 PM |
| how to pause another process? | daneensign | UNIX for Dummies Questions & Answers | 1 | 02-14-2006 12:27 AM |
| system("PAUSE") Problem..... | mbolthouse | High Level Programming | 2 | 10-03-2001 01:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Pause for response from the log file
Hello,
I am writing a shell script to search an active log file. If an "error" or "aborted" found, echo an acknowledgment message and wait until the user presses ENTER key. tail -f log.file |nawk ' {print $0} $0 ~ /error/ { print "Error found. Press ENTER to acknowledge." getline i < "-" } $0 ~ /aborted/ { print "Error found. Press ENTER to acknowledge." getline i < "-" } ' Because this is an active log file, the messages keep coming to the log file all the time. The next incoming message, after error or aborted found, is read as response to the message. I may have multiple Putty sessions running at same time. Only Putty session that displayed message can accept the response from user. Thanks. George |
|
||||
|
Thank you MajorMark.
my purpose for this scripting is to provide exception processing notification and acknowledgement. I want to pause the screen that is scrolling as the messages are coming to the log. The user may not catch the error while the screen is scrolling other informational messages. If an error is found, I would like to pause for a user response. Once the user presses ENTER, the screen resumes scrolling again. With the code above it paused, but did not wait for a user response. |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|