Page 1 of 1

Linux/CUPS script for turning on printer

Posted: Wed Nov 25, 2009 10:27 pm
by Tozz
I created a little script that checks my CUPS printer spool for jobs that are queued. If a job is queued my printer is probably off and I use HomeSeer to turn it on. Can be modified to use Plugwise Source webserver just as easy. My printer is connected to a Plugwise plug, but this should work for any other device module in HomeSeer.

Code: Select all

#!/bin/bash
#
# My HP4700 printer uses 20 Watts in "powersave" mode.
# this is roughly 175 kWh a year. Money better spend
# elsewhere. 
#
# We use a Plugwise (www.plugwise.com) module to turn 
# the printer on/off. Any HomeSeer enabled device
# (X10, ZWave, etc) can be used.
#
# Variables
# CUPSURL = IP/hostname of CUPS server
# PRINTER = CUPS printer device
# DEVICE = HomeSeer Device ID
# HSURL = IP/hostname of HomeSeer
#
CUPSURL=192.168.0.250
PRINTER=HP4700
DEVICE=5473
HSURL=192.168.0.62
#
#
#
#
#
# Create a temporary file
TMPFILE=`mktemp`
#
# Download CUPS data from this printer
wget http://$CUPSURL:631/printers/$PRINTER -O $TMPFILE -q
#
# Do a count on string "pending since". 1 for each job
QUEUESIZE=`cat $TMPFILE | grep "pending since" | wc -l`
#
# If queuesize is larger then 0 there is a print job queued
# then turn printer on.
if [ $QUEUESIZE -gt 0 ];
then
  # Turn device on.
  wget --post-data "bookmark=$DEVICE&IFrameRef=$DEVICE&ref_page=stif&control_device=$DEVICE&action_on=On&selectdim=0" http://$HSURL/stif -O /dev/null -q
fi

#
# Delete temporary file
rm $TMPFILE

Linux/CUPS script for turning on printer

Posted: Thu Dec 03, 2009 3:52 pm
by jakkes
Does anybody know to script like above for a windows XP/Vista or Windows 2003 Server?

Linux/CUPS script for turning on printer

Posted: Thu Dec 03, 2009 4:10 pm
by Alexander
And than for HS you mean?

Alexander

Linux/CUPS script for turning on printer

Posted: Thu Dec 03, 2009 4:39 pm
by Bwired
Useful smart script!
Yep those HP printers really suck when it comes to energy consumption, I have a small HP printer which takes 12 watt when its off [:(!] So I switch it off too.

<hr noshade size="1"><font size="1">Pieter Knuvers
http://www.bwired.nl <i>Online House in the netherlands. Domotica, Home Automation.</i></font id="size1">

Re: Linux/CUPS script for turning on printer

Posted: Tue Dec 29, 2009 12:02 am
by Tozz
Do you happen to know if HP printers do anything special when you flick the switch on the printer itself? When i turn it off using the switch it seems to do 'something'. It makes some noise before it actually goes off. So I'm wondering if it might be a bad idea to turn it off by cutting power.

I have a HP 4700 DTN printer.

Re: Linux/CUPS script for turning on printer

Posted: Sun Jan 24, 2010 8:43 pm
by jakkes
Finaly....., i have a linux box.....

Now i would like to use this script, but where do i place it? And how to run it?

I am a linux newbie, please stay friendly....

Re: Linux/CUPS script for turning on printer

Posted: Sun Jan 24, 2010 10:52 pm
by jheerink
I don't know for the HP4700 but i;am sure the older HP laserprinters (4500 fi)
need to cooldown after a print job, So when you switch it off it will continue to run
a while. To prevent the fuser from overheating. If you would switch it off with a plugwise
it could be damaged because it can,t finish the coolcycle.