Welcome to the Linux Foundation Forum!

Test if printer is turned off or unplugged.

Options

Hello all. I am trying to test if a particular printer is available before continuing in a script. Have searched other sites and cannot find much on this subject.
What I've tried so far.

if lpstat -t -p MG2500 ;then
echo "Printer Is Ready"
read -n1 -r -p "Press Any Key To Continue" key
exit
else
echo "Printer Is Unavailable"
read -n1 -r -p "Press Any Key To Continue" key
exit
fi

But this only test the lpstat command and says Printer is ready even when it's turned off. Is there a command that will succeed if printer is available or fail if its not? Thanks in advance.

Categories

Upcoming Training