Scrawls from Preston...

Powered by Pelican.

Thu 18 December 2008

Script to alert you when printing is done

At work I'm doing a bunch of printing of some large documents. I wanted a way of being notified when it was done printing. The action to take is up to you, I'm using curl to load a python CGI on a server to send an email/SMS to my phone. If you want to watch your non-default printer - just use the -P flag to lpq.

#!/bin/bashLPQSTAT=`lpq | head -1 | awk '{ print $NF }'`while [ $LPQSTAT = 'printing' ];do echo $LPQSTAT sleep 5 LPQSTAT=`lpq | head -1 | awk '{ print $NF }'` donecurl ....exit 0