|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
BRO...wait $! is probably not the right solution and it's not working also for this particular script
What I need is instead of sleep I want few lines of code which will check for the PID in the last line(tail -1) of current_date.log file in /abc/xyz directory....and check if the same PID count is 2 then it should execute the next job.... (Ex:- more Jan_12.log Mon Jan 12 01:43:48 Program: saimptlogi: PID=12409: Started by rms Mon Jan 12 01:45:50 Program: saimptlogi: PID=12409: Thread 1 - Terminated Successfully ) Please have a thorough look at my initial script and help me....I need these help badly... |
| Sponsored Links |
|
|
|
|||
|
So instead of sleep 140 in the above mentioned script.....can I put it like this..will it work?:
cd $MMHOME/log while do more $(ls -ltr|tail -1|cut -c 55-70)|grep "saimptlogi"|tail -2f|perl -ne '/PID=([0-9]+):/ && { $pid{$1}++; if ($pid{$1} >= 2)' sleep 60 done Last edited by satyajit007; 02-26-2009 at 05:11 AM.. |
|
||||
|
Um, no, because the tail won't exit with the -f option, and the PERL script won't exit by itself. (Also, you don't need "more" here). This is more what you're looking for Code:
cd $MMHOME/log
logfile=$(ls -ltr|tail -1|cut -c 55-70)
if ! tail -2f $logfile |
perl -ne '/saimptlogi/ && /PID=([0-9]+):/ && do { $pid{$1}++; exit 1 if ($pid{$1} >= 2) }'
then
echo "Started"
fiNote, it does not exit or return until the process has started! If it's not working for you, try increasing the tail -2f to tail -4f or something. That allows more lines of backlog to be seen. But it also means you might "catch" prior running instances. Last edited by otheus; 02-26-2009 at 07:48 AM.. Reason: bad syntax |
|
|||
|
syntax error
Sir....It is giving the following error.....
savouch_75002_20090210_20090226160640.out/appdb/product/agent/tmp/AAAjzaWJcsyntax error at -e line 1, near "; exit" Execution of -e aborted due to compilation errors. Started PL/SQL procedure successfully completed. /appdb/product/batch/rms/pos/RTLOG_GCN1.TXT 2 ./saimptlogi_batch.sh[17]: ./saimptlogi: not found syntax error at -e line 1, near "; exit" Execution of -e aborted due to compilation errors. Started Also i think we should close { $pid{$1}++; exit 1 if ($pid{$1} >= 2)' .....with a } bracket ??? Last edited by satyajit007; 02-26-2009 at 06:51 AM.. |
|
|||
|
Thanks...I will test it and inform you abt the result....
Last edited by satyajit007; 02-27-2009 at 12:54 AM.. |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Tags |
| scripting, shell |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| alternate to set -x in csh scripts | sais | Shell Programming and Scripting | 3 | 10-12-2008 09:04 AM |
| alternate lines | pstanand | Shell Programming and Scripting | 6 | 03-18-2008 11:14 PM |
| option followed by : taking next option if argument missing with getopts | gurukottur | Shell Programming and Scripting | 2 | 03-17-2008 12:46 PM |
| Alternate way for echo. | senthil_is | Shell Programming and Scripting | 5 | 03-05-2008 09:12 AM |
| Alternate command for cut | Mohammed | Shell Programming and Scripting | 2 | 10-20-2006 08:42 AM |