lpool

We have several printers in our student lab and it is very nice to be able to split the printing between them. Since we run linux exclusivly, I developed a samba/lpd solution to the problem by using the output filters (man printcap) available in lpd. Basically, we have a printcap which looks like this:

pooled:\
        :sd=/var/spool/lpd/pool:\
	:mx#0:\
	:sh:\
	:if=/usr/local/bin/lpool:\
	:lp=/dev/null:
lp1:\
	:sd=/var/spool/lpd/dec1:\
	:mx#0:\
	:sh:\
	:lp=/dev/ttyS1:\
	:br=9600:
lp2:\
	:sd=/var/spool/lpd/dec2:\
	:mx#0:\
	:sh:\
	:lp=/dev/ttyS0:\
	:br=9600:

There are only two "real" printers in this setup (lp1 and lp2), the pooled printer is a dummy which prints to /dev/null and filters all requests through an input filter (/usr/local/bin/lpool). This filter is a simple perl script which will

  • Rotate the default printer
  • Find a printer which is not busy before printing out information
  • Give up after a specified ammount of time (sending the error back to lpd)
You can download a copy of lpool by clicking here. Be sure to edit the file so that it knows about which printers are available-- you may also encounter difficulties if you are not using Berkely lpd (I used v 1.1 1994/05/23 -- which is installed by RedHat Linux 4.2), namely you will need to edit line 79 so that the "no entries" message is correct for your server. You can find out the correct message by issuing this command:

lpq -P my_printer_name_here

And if there isn't anything in the queue, you can copy that text to line 79 of lpool.