Python and Linux print queues

Larry Bates lbates at swamisoft.com
Thu Dec 12 11:21:45 EST 2002


I am working on a project and would like to be able to print to
Linux printers (not just default LPR).

I've tried using the following code I found in a thread somewhere:

import os
p=os.popen('lpr -P printer2','w')
p.write('test\n')
p.close()

This runs without errors, but it doesn't work.

This code on the other hand DOES work (so I know
that the print queue is working), but this method doesn't
solve the problem that I have.  I want to be able to open
the printer and print to it until I close it.  I suppose I
could write the output to a file and at the end CAT it
to the printer, but it seems like there should be an
easier way.

os.system('echo test | lpr -P printer1'))

Thanks in advance for any assistance.

Larry Bates

lbates at swamisoft.com





More information about the Python-list mailing list