![]() |
Hello and Welcome from 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 |
| Hanging port? | NycUnxer | UNIX for Dummies Questions & Answers | 1 | 01-09-2008 02:21 PM |
| hanging sockets!??! | Naanu | SUN Solaris | 1 | 02-08-2007 09:15 PM |
| Hanging commands | jOOc | UNIX for Dummies Questions & Answers | 0 | 07-05-2006 12:14 PM |
| how to tell if process is hanging | dangral | UNIX for Dummies Questions & Answers | 2 | 01-07-2004 08:43 AM |
| mq_open Hanging | Deepa | High Level Programming | 0 | 06-24-2003 07:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Problem with awk hanging
I have a problem with an awk command.
I have a expect script running on one node that is executing a command on another node. Both nodes are Linux. The script on the remote node is supposed to check a couple of logs after "type" notifications. I am using tail and awk to do that. The env NO_OF_NOT shall step each time a type=1 notification has been found and when 6 are found the script should exit: ----------------------------------------- NO_OF_NOT=6 # Wait for $NO_OF_TP notifications echo "Will wait for $NO_OF_TP start-notifications." echo "Waiting..." tail -F -n0 ~/consolelogs/start* \ | awk '/type=9/ {print "Servlet not Started Error: "; print} \ /type=5/ {print "Application could not be Started Error: "; print} \ /type=1/ {++n; print; if (n=='$NO_OF_TP') exit}' >& 1 2> /dev/null echo "All notifications received" ------------------------------------------ The script works fine but it does not do exit when NO_OF_NOT has been reached. What am I doing wrong? Kind Regards /Andreas |
|
||||
|
Sorry I missed that.
But it still will not work. It just hangs and will not stop. ----------------------------------------- NO_OF_NOT=6 # Wait for $NO_OF_NOT notifications echo "Will wait for $NO_OF_NOT start-notifications." echo "Waiting..." tail -F -n0 ~/consolelogs/start* \ | awk 'BEGIN { n = 0 } /type=9/ {print "Servlet not Started Error: "; print} \ /type=5/ {print "Application could not be Started Error: "; print} \ /type=1/ {++n; print; if (n=='$NO_OF_NOT') exit}' >& 1 2> /dev/null echo "All notifications received" ------------------------------------------ |
|
||||
|
Use a variable in awk:
Code:
tail -F -n0 ~/consolelogs/start* \
| awk -v NON=$NO_OF_NOT 'BEGIN { n = 0 }
/type=9/ {print "Servlet not Started Error: "; print} \
/type=5/ {print "Application could not be Started Error: "; print} \
/type=1/ {++n; print; if (n==NON)exit}' >& 1 2> /dev/null
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|