1819804 Members
2876 Online
109607 Solutions
New Discussion юеВ

check status for printer

 
SOLVED
Go to solution
pratapvfr
Advisor

check status for printer

i have few hpux box which are using network perinter,
i want to write a small script which will check the printer status and if status is disable it will enable and send me email.
8 REPLIES 8
avizen9
Esteemed Contributor

Re: check status for printer

for enable and disable printer you need to use below commands.

enable
disable

if you want to get email you should have install sendmail in your hpux box.

for writting script i believe you can try with sell script in hpux, logic should be declair printer alias, and with if condition check the status for printer, at present i dont have any script but should try something this.
this may help.

thanks
Suraj K Sankari
Honored Contributor

Re: check status for printer

Hi,

Use lpstat -t

The "lpstat" command with the "-t" option gives you total information about the printer status. This option is generally the most useful, but the printout can be lengthy if you have a large number for printers configured.

From the output of the above command you can write a script as per your requirment.

Suraj
pratapvfr
Advisor

Re: check status for printer

okey,
commands looks ok, but if will get some script then will be good,
avizen9
Esteemed Contributor
Solution

Re: check status for printer

HI,
you may try something below, if its work ok then add sendmail to get email, let us know how it goes, thanks,


printer=hplaserjet
printerstatus=`lpstat -p\`echo $printer\`|awk {'print $5'}`

if [ $printerstatus!= "enabled" ]
then
enable $printer
fi
pratapvfr
Advisor

Re: check status for printer

ok, i have tried with it, looks fine, but not complete solusion which i require,

its shows printer satatus and also able to enable it.

how to get email when it enable? i am trying with sendmail, anyone can guide me for this.
Dennis Handly
Acclaimed Contributor

Re: check status for printer

>how to get email when it enable?

Just change it to:
if [ $printerstatus != "enabled" ]; then
enable $printer
echo "printer enabled" | mailx -s "Enabling printer: $printer" mail@foo.com
fi
avizen9
Esteemed Contributor

Re: check status for printer

also you can try with this

sendmail -F printername abcd@domain.com /etc/message.txt

here message.txt is the message which you want to send when printer will enable.

so here this sendmail line you need to write for each and every printer, hope this will help, let us know, thanks,
pratapvfr
Advisor

Re: check status for printer

thanks for all your efford here, its work fine.