HI Guys
Want help in writing a Script for check and enable the printer if any any is disable in HP-UX automatic after every half hour...
Thanks...:wall:
HI Guys
Want help in writing a Script for check and enable the printer if any any is disable in HP-UX automatic after every half hour...
Thanks...:wall:
OK, so how did you plan to do it, or what have you tried?
Try something like this to get started on the sorts of things you will need to do.
You might also like to try this
Have a read, have a go and then let us know if you need some more help with your chosen approach.
Robin
Hi Guys
Please check whether the below mention scipt is fine or not to enable a disable printer�
#!/usr/bin/ksh
# Script To check and enable printers that have gone down.
if [ $# = 1 ]
then
date=`/usr/bin/date`
lpstat $1 | grep Warning > /dev/null 2>&1
if [ $? = 0 ]
then
echo "$1 down at $date" >> /var/tmp/lp/errlog
ps -ef | grep lp >> /var/tmp/lp/$1pslog
tail -50 /var/spool/lp/log >> /var/tmp/lp/$1lplog
tail -50 /var/adm/syslog/syslog.log >> /var/tmp/lp/$1syslog
dmesg >> /var/tmp/lp/$1dmesglog
echo "Cancelling Print Requests for $1" >> /var/tmp/lp/errlog
cancel -a -e -i $1
enable $1
date1=`/usr/bin/date`
echo "$1 brought up at $date1" >> /var/tmp/lp/errlog
else
exit
fi
else
echo Improper Usage
fi
I have a few observations. I apologies if listing them make it seem a little terse for a response, but I will end up in long winded discussion with myself otherwise.
lpstat -p
(no other parameters) and taking action for each printer that is not in a good state?tail -50 /var/spool/lp/log
may not get the information you are interested in. Perhaps use grep
to select information about your print queue and then tail off the last few records.Warning
, but that doesn't cover a queue that is DOWN
These are observations only, and you certainly have the makings of a sensible approach. If it meets your needs, there is nothing else to do.
Robin