I have been using this script:  
No guarantees tho!
0,5,10,15,20,25,30,35,40,45,50,55 6-20 * * 1-5
/usr/local/scripts/autoenableq > /usr/local/scripts/autoenableq.err 2>&1

#!/usr/bin/ksh
# NAME:/usr/local/scripts/autoenableq
# Script runs lpstat and awk command to check if printers are enabled
# This script works faster by calling enq command than calling lpstat
for remote printer first.
# DATE: 
# WRITTEN: 
#
#
alert1 ()
{
DATE=`date`
MAIL="[EMAIL PROTECTED]"
THISHOST=`uname -n`
enq -As  | grep "DOWN" | awk '{print $1}' > /tmp/lpstat.t1 
for i in `cat /tmp/lpstat.t1`
    do
    enable $i
    done
echo "The date/time is $DATE." >> /tmp/lpstat.t2
#echo "$i ">> /tmp/lpstat.t2
for p in `cat /tmp/lpstat.t1`
  do 
  grep "$p" /tmp/prnt.list >> /tmp/lpstat.t2
  done
echo "\nThese queues were DOWN and have been enabled.">>/tmp/lpstat.t2

mail -s "$THISHOST Printer Status" $MAIL < /tmp/lpstat.t2 
sleep 10
}

alert2 ()
{
DATE=`date`
MAIL="[EMAIL PROTECTED]"
THISHOST=`uname -n`
enq -As  | grep "CONNECT" |awk '{print $1}' >/tmp/lpstat2.t1
echo "The date/time is $DATE." >> /tmp/lpstat2.t2 
for i in `cat /tmp/lpstat2.1`
   do 
   grep "$i" /tmp/prnt.list >> /tmp/lpstat2.t2
   done
echo "\nThese queues are in a CONNECT STATE." >> /tmp/lpstat2.t2 
mail -s "$THISHOST Printer Status" $MAIL < /tmp/lpstat2.t2 
sleep 10
}
#rm -f /tmp/lpstat.1    
rm -f /tmp/lpstat.t1 
rm -f /tmp/lpstat.t2
rm -f /tmp/lpstat2.t2
#rm -f /tmp/lpstat2.1
enq -As  | grep "DOWN" | awk '{print $1}' > /tmp/lpstat.1 
enq -As  | grep "CONNECT" |awk '{print $1}' > /tmp/lpstat2.1 
grep 331 /var/spool/lpd/pio/"put hostname here"/custom/* |awk -F:
'{print $2,$7}'>/tmp/prnt.list 
if [ -s /tmp/lpstat.1  ]; then
   alert1
fi

if [ -s /tmp/lpstat2.1 ]; then
    alert2
fi



Sean 
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to