The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-19-2006
jisc jisc is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 6
thanks for the link ranj

Code:
#! /bin/ksh
curr_date = `date "+%m.%d"`
file=/datamart/logs/LOG.`date "+%m.%d"`

tail -f $file |&
while read -p err_line; 
do [[ $err_line = "*** PROCESS IS DEAD: RW [Signal w/ Core dump: 10] ***" ]] && {
  echo "mailx scripts goes here"
 }
done
i know too litlle of scripting so i'd like to ask if you guys can help me debug this code. the code above works, because the whole is specified, but i just want a pattern match not an absolute match of the line so i'd like to change it to "*PROCESS IS DEAD*" but its not working. can you help me out on this? how does pattern matching work on scripting?

and one more important thing, i'd like to add as you can see my log file name is LOG.MM.DD where MM is month and DD is day. How can I add a code in the script to make the tail command stop and start again on 12:05am (when log file name will change). basically i was thinking of changing the while part to while read -p err_line && curr_date = `date "+%m.%d"` and then put the whole code to a loop.

so i was thinkng of changing the script from that above to this:

Code:
#! /bin/ksh
do
curr_date = `date "+%m.%d"`
file=/datamart/logs/LOG.`date "+%m.%d"`
tail -f $file |&
while read -p err_line && curr_date = `date "+%m.%d"`; 
do [[ $err_line = "*PROCESS IS DEAD*" ]] && {
  echo "mailx scripts goes here"
 }
done
done
but its not working, can you guys help me correct this?