[lug] Anyone want to help me with this script?

Jarosko, Bill Bill_Jarosko at adc.com
Tue Aug 22 15:55:06 MDT 2000


This is just something I've been playing with and was wondering if I had
done anything that is totally unacceptable. 


#!/bin/sh

# We *must* run the greps in the
# current process, so that "grep -v $$" can filter out the pid of the
# current script. This prevents matching if the name of the current
# script includes a string matching a program.
# The nested whiles are used to keep the loop going.
# If for some reason the program is not running the nested while tries to
call the program
# and pops out. The first while checks to see if the program is running, if
so it continues
# back to the nested while.


echo "Enter the Program you wish to watch here :"
read name
echo $name "is string that will be watched" 
echo "Enter the path to the Executable includng the executable :"
read exec
echo $exec "is the command path"
var=0
var1=0
 while [ $var -le 0 ]
  do
   if ps -u `id -u` |grep -vw $$|grep $name > /dev/null
    then  
     while [ $var1 -le 0 ]
      do
       if ps -u `id -u` |grep -vw $$|grep $name > /dev/null
        then 
          echo $name "is running"
           sleep 300 
        else
          $exec || echo "$name no longer running" |mail root at localhost &&
var1=1
       fi
     done
    else echo "$name will not come back up" |mail root at localhost || exit1
      var=1
   fi
 done
exit 0



"Those who don't understand UNIX are condemned to reinvent it, poorly. " --
Henry Spencer 
This maybe exactly what he meant......

Thanks,
Bill





More information about the LUG mailing list