Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

lpd client in python

571 views
Skip to first unread message

Peter Henning

unread,
Nov 26, 1996, 3:00:00 AM11/26/96
to

Hi

A quick question...has anyone written a Python module that talks directly
to an lpd daemon for spooling print jobs? The protocol can't be all that
hard.

I'm sick of using popen("/usr/bin/lpr -Pfoo", "r")!!

Jeffrey C. Ollie

unread,
Nov 27, 1996, 3:00:00 AM11/27/96
to

-----BEGIN PGP SIGNED MESSAGE-----

If someone can supply me with a link to a description of the protocol,
I'd take a whack at it.


[A copy of the headers and the PGP signature follow.]

Date: Wed, 27 Nov 1996 09:02:31 -0600
Newsgroups: comp.lang.python
Organization: netINS, Des Moines, IA, USA
References: <Pine.LNX.3.91.96112...@ruby.gem.co.za>
Subject: Re: lpd client in python

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: AnySign 1.3 - A Python tool for PGP signing e-mail and news.

iQCVAwUBMpxYC5wkOQz8sbZFAQH/kgP/c8SZdR6XX4mTQyUUuojmECsXiTPlFRxM
kwK27eUO3986GdlLPcK/1CtzwDCdlBvgH0Mbojtep8mxiDhEusrLBPRpVzlyPx63
kaMdrIpZ/WO5SZ9HyU4l9z1JSqLegzUgly5WlEIgP0k6w4kr079/ErcV1zDgEvkn
vsQJd0rYWoo=
=LIy4
-----END PGP SIGNATURE-----
--
Jeffrey C. Ollie | Should Work Now (TM)
Iowa Network Services System Administrator |

Jack Jansen

unread,
Nov 28, 1996, 3:00:00 AM11/28/96
to

je...@netins.net (Jeffrey C. Ollie) writes:

>-----BEGIN PGP SIGNED MESSAGE-----

>On Tue, 26 Nov 1996 08:18:50 GMT, Peter Henning <pet...@gem.co.za> wrote:
>>
>>A quick question...has anyone written a Python module that talks directly
>>to an lpd daemon for spooling print jobs? The protocol can't be all that
>>hard.
>>
>>I'm sick of using popen("/usr/bin/lpr -Pfoo", "r")!!

>If someone can supply me with a link to a description of the protocol,
>I'd take a whack at it.

Yes, that would be very nice! It would also allow me to write an lpr
that works from my mac (or a dos box, or.....).
--
--
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack....@cwi.nl | ++++ if you agree copy these lines to your sig ++++
http://www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm

Peter Henning

unread,
Nov 29, 1996, 3:00:00 AM11/29/96
to

On Wed, 27 Nov 1996, Jeffrey C. Ollie wrote:

> On Tue, 26 Nov 1996 08:18:50 GMT, Peter Henning <pet...@gem.co.za> wrote:
> >
> >A quick question...has anyone written a Python module that talks directly
> >to an lpd daemon for spooling print jobs? The protocol can't be all that
> >hard.
>

> If someone can supply me with a link to a description of the protocol,
> I'd take a whack at it.

Well, RFC1179 covers the basics...it's a very ugly little protocol IMHO.

David Poole

unread,
Nov 29, 1996, 3:00:00 AM11/29/96
to

On Thu, 28 Nov 1996 12:59:57 GMT, ja...@cwi.nl (Jack Jansen) wrote:

>je...@netins.net (Jeffrey C. Ollie) writes:
>
>>-----BEGIN PGP SIGNED MESSAGE-----
>

>>On Tue, 26 Nov 1996 08:18:50 GMT, Peter Henning <pet...@gem.co.za> wrote:
>>>
>>>A quick question...has anyone written a Python module that talks directly
>>>to an lpd daemon for spooling print jobs? The protocol can't be all that
>>>hard.
>>>

>>>I'm sick of using popen("/usr/bin/lpr -Pfoo", "r")!!
>

>>If someone can supply me with a link to a description of the protocol,
>>I'd take a whack at it.

The "official" LPD protocol is documented in rfc1179.txt (rfc==Request
For Comment) available from ftp://nic.ddn.mil/rfc. The protocol is
pretty straightforward.

I'm just now exploring using Python as a network testing tool. An lpr
would be a cool tool!


Guido van Rossum

unread,
Nov 30, 1996, 3:00:00 AM11/30/96
to

> Yes, that would be very nice! It would also allow me to write an lpr
> that works from my mac (or a dos box, or.....).

Unfortunately, this wouldn't make printing available from Python for
most DOS/Windows and Mac users -- they have a local printer that needs
to be addressed through some OS dependent printing API.

--Guido van Rossum (home page: http://www.python.org/~guido/)

Jack Jansen

unread,
Nov 30, 1996, 3:00:00 AM11/30/96
to

Recently, Guido van Rossum <gu...@CNRI.Reston.VA.US> said:
> > Yes, that would be very nice! It would also allow me to write an lpr
> > that works from my mac (or a dos box, or.....).
>
> Unfortunately, this wouldn't make printing available from Python for
> most DOS/Windows and Mac users -- they have a local printer that needs
> to be addressed through some OS dependent printing API.

Correct, but from python it would allow an interface like
import lprclient
sys.stdout = lprclient.open('hostname', 'printername')
or something similar.

And maybe one day I'll feel *very* adventurous and write a device
driver in Python:-)

Jeffrey C. Ollie

unread,
Dec 2, 1996, 3:00:00 AM12/2/96
to

-----BEGIN PGP SIGNED MESSAGE-----

On Sat, 30 Nov 1996 20:48:27 GMT, Guido van Rossum <gu...@CNRI.Reston.VA.US> wrote:
>> Yes, that would be very nice! It would also allow me to write an lpr
>> that works from my mac (or a dos box, or.....).
>
>Unfortunately, this wouldn't make printing available from Python for
>most DOS/Windows and Mac users -- they have a local printer that needs
>to be addressed through some OS dependent printing API.

True, but the DOS/Windows and Mac printing APIs are fairly complex
(well, I suppose DOS/Windows users could send data to LPT:) and not
something that could be implemented in a day or two. The UNIX lpr
protocol is fairly simple and should be easy to implement. It won't be
the solution for everyone, but it'll be a handy tool to have around...


[A copy of the headers and the PGP signature follow.]

Date: Mon, 02 Dec 1996 08:49:36 -0600


Newsgroups: comp.lang.python
Organization: netINS, Des Moines, IA, USA

References: <Pine.LNX.3.91.96112...@ruby.gem.co.za> <slrn459om0...@worf.netins.net> <jack.84...@news.cwi.nl> <199611302048.PAA09552@monty>


Subject: Re: lpd client in python

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: AnySign 1.3 - A Python tool for PGP signing e-mail and news.

iQCVAwUBMqLsipwkOQz8sbZFAQGI2QQA4Lylwp3TGKgYCaRMCtk+kb8pNYHn8BIR
q4BjS2L2qE135ppK3VGvptOyaXZTbSTgp4HbnzdXTTfoBoxrGnSiPSksRVXBREYF
K3zXByrPrchqYijHCadP2NS01W5omlyV2Iq8SKJwq6AdkGkGjkAQwl+8oUDdjwSp
4r6C2sDRmrs=
=CDmY


-----END PGP SIGNATURE-----
--
Jeffrey C. Ollie | Should Work Now (TM)

Python Hacker, Mac Lover |

Scott Simmonds

unread,
Dec 3, 1996, 3:00:00 AM12/3/96
to

Peter Henning <pet...@gem.co.za> writes:

>
> On Wed, 27 Nov 1996, Jeffrey C. Ollie wrote:
>

> > On Tue, 26 Nov 1996 08:18:50 GMT, Peter Henning <pet...@gem.co.za> wrote:
> > >
> > >A quick question...has anyone written a Python module that talks directly
> > >to an lpd daemon for spooling print jobs? The protocol can't be all that
> > >hard.
> >

> > If someone can supply me with a link to a description of the protocol,
> > I'd take a whack at it.
>

> Well, RFC1179 covers the basics...it's a very ugly little protocol IMHO.

Unix Network Programming by W. Richard Stevens has a slightly more
understandable description of the protocol in chapter 13, and describes
a C program which replaces lpr.
The source for BSD's lpd.c also contains some clues.

Scott.

--
Scott Simmonds | 1 612 456 3737 (W)
Lockheed Martin Tactical | 1 612 456 3098 (Fax)
Defense Systems | 3333 Pilot Knob Road
Airborne Systems Division | Eagan, MN, 55121
RAAF AIR 5276 DMS | scott.s...@lmco.com

Jeffrey C. Ollie

unread,
Dec 3, 1996, 3:00:00 AM12/3/96
to

-----BEGIN PGP SIGNED MESSAGE-----

On Fri, 29 Nov 1996 08:41:49 GMT, Peter Henning <pet...@gem.co.za> wrote:
>On Wed, 27 Nov 1996, Jeffrey C. Ollie wrote:
>
>> On Tue, 26 Nov 1996 08:18:50 GMT, Peter Henning <pet...@gem.co.za> wrote:
>> >
>> >A quick question...has anyone written a Python module that talks directly
>> >to an lpd daemon for spooling print jobs? The protocol can't be all that
>> >hard.
>>
>> If someone can supply me with a link to a description of the protocol,
>> I'd take a whack at it.
>
>Well, RFC1179 covers the basics...it's a very ugly little protocol IMHO.

Yes, it is ugly... I had forgotten for a second that UNIX won't let
you open reserved ports unless you are root - that kind of kills the
project on UNIX unless the script that you want to print from is
already running as root. So it seems that the best solution on UNIX is
to just open a pipe to the standard lpr command.

Another factor is that the protocol described in RFC 1179 doesn't
really provide a good way for a program to insert a job into a
queue. Rather it appears to be designed for transferring jobs between
servers. I'm trying to track down the source to the BSD lpr client to
see how that works.

So it doesn't look like this is anywhere close to being a simple
project. Unfortunately I don't have the time or inclination for a
project such as this looks like it's turning into, so I wouldn't
expect much.

[A copy of the headers and the PGP signature follow.]

Date: Tue, 03 Dec 1996 23:01:07 -0600


Newsgroups: comp.lang.python
Organization: netINS, Des Moines, IA, USA

References: <slrn459om0...@worf.netins.net> <Pine.LNX.3.91.961129...@ruby.gem.co.za>


Subject: Re: lpd client in python

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: AnySign 1.3 - A Python tool for PGP signing e-mail and news.

iQCVAwUBMqUFmJwkOQz8sbZFAQF6DQP/bLT9WA6mOwCLYDhZYrfXBbE3Hd79CvXC
3LzspjQ0VNLshgna/O75XI7KWEmdJ5ZRkfop4NT3kYB45GI5SICbkK48g7w8KI0v
WTtI6tXYff2zQJtDUdbIHDHWRdop1VClvvKHpH71RQl/GZChuL2WOo0Ogqtre6N6
5d+1h8TIEnA=
=l92+
-----END PGP SIGNATURE-----

Roger Masse

unread,
Dec 4, 1996, 3:00:00 AM12/4/96
to

Jeffrey C. Ollie writes:
>
> Yes, it is ugly... I had forgotten for a second that UNIX won't let
> you open reserved ports unless you are root - that kind of kills the
> project on UNIX unless the script that you want to print from is
> already running as root. So it seems that the best solution on UNIX is
> to just open a pipe to the standard lpr command.

For UNIX this may be OK. NT also has an 'lpr' command that can spool
files to remote lpds. It, unfortunately (at least on 3.51) cannot
read from standard input. It must be passed a file on the command
line. I agree that lpr on NT is not the prefered way to print on
this platform and writing a thin verneer over 'lpr' might seem mostly
unneeded. However, if we are looking to converge on an interface
for lpd style printing and the cleanest way is via 'lpr', it might be
worth considering a cross-platform approach.

--

Regards,

Roger E. Masse, Systems Engineer
Corporation for National Research Initiatives
1895 Preston White Drive, Suite 100
Reston, Virginia, USA 22091
Internet: rma...@CNRI.Reston.VA.US

To find out why 'Python' is my favorite
language, see: <http://www.python.org/>

Jeffrey C. Ollie

unread,
Dec 4, 1996, 3:00:00 AM12/4/96
to

-----BEGIN PGP SIGNED MESSAGE-----

On Thu, 05 Dec 96 00:32:38 GMT, Christopher Tavares <tav...@connix.com> wrote:
>In article <slrn45aa1d...@worf.netins.net>, je...@ollie.clive.ia.us (Jeffrey C. Ollie) wrote:
>>-----BEGIN PGP SIGNED MESSAGE-----
>>
>>On Fri, 29 Nov 1996 08:41:49 GMT, Peter Henning <pet...@gem.co.za> wrote:
>>>On Wed, 27 Nov 1996, Jeffrey C. Ollie wrote:
>>>
>>>> On Tue, 26 Nov 1996 08:18:50 GMT, Peter Henning <pet...@gem.co.za> wrote:
>>>> >
>>>> >A quick question...has anyone written a Python module that talks directly
>>>> >to an lpd daemon for spooling print jobs? The protocol can't be all that
>>>> >hard.
>>>>
>>>> If someone can supply me with a link to a description of the protocol,
>>>> I'd take a whack at it.
>>>
>>>Well, RFC1179 covers the basics...it's a very ugly little protocol IMHO.
>>

>>Yes, it is ugly... I had forgotten for a second that UNIX won't let
>>you open reserved ports unless you are root - that kind of kills the
>>project on UNIX unless the script that you want to print from is
>>already running as root. So it seems that the best solution on UNIX is
>>to just open a pipe to the standard lpr command.
>>

>>Another factor is that the protocol described in RFC 1179 doesn't
>>really provide a good way for a program to insert a job into a
>>queue. Rather it appears to be designed for transferring jobs between
>>servers. I'm trying to track down the source to the BSD lpr client to
>>see how that works.
>>
>>So it doesn't look like this is anywhere close to being a simple
>>project. Unfortunately I don't have the time or inclination for a
>>project such as this looks like it's turning into, so I wouldn't
>>expect much.
>

>Steven's _Unix_Network_Programming_, chapter 13, has a very good description
>of lpr and lpd.

Fortunately, I have a copy of this excellent book (wish I had
remembered that lpr was in there). After re-reading chapter 13, it's
clear to me that a simple Python module won't do much good on
UNIX. The UNIX lpr implementation runs setuid root so that it can copy
files into the spool directory; it doesn't use the protocol described
in the RFC at all.

A solution for Macs and PCs is certainly possible though. It will take
more work because I haven't done any work with Python on Macs or PCs.
I'll look into getting a solution going on a Mac, then on a PC running
95/NT. Don't expect anything for a month or so, though.

[A copy of the headers and the PGP signature follow.]

Date: Wed, 04 Dec 1996 23:13:02 -0600


Newsgroups: comp.lang.python
Organization: netINS, Des Moines, IA, USA

References: <slrn459om0...@worf.netins.net> <Pine.LNX.3.91.961129...@ruby.gem.co.za> <slrn45aa1d...@worf.netins.net> <585558$r...@beast.connix.com>


Subject: Re: lpd client in python

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: AnySign 1.3 - A Python tool for PGP signing e-mail and news.

iQCVAwUBMqZZ5JwkOQz8sbZFAQFT+wP/ZmFqXG1hbWvreoR4GI40ANIimnZ40AGV
Hr1qZDSSpjGkqHG6xT5y9iZO6mze8A5fjJDEQWfIzHjFuhYS0fouKcwswoX5Oo7r
zvh3ZVowIaHdfdnemVYMKXtAGca74Enb3qsNsh7lyCc31MfZ9655J/ciFYesYLGI
gPKtriOFns8=
=Rr1x
-----END PGP SIGNATURE-----

Christopher Tavares

unread,
Dec 5, 1996, 3:00:00 AM12/5/96
to

-Chris


Jeffrey C. Ollie

unread,
Dec 5, 1996, 3:00:00 AM12/5/96
to python...@python.org

-----BEGIN PGP SIGNED MESSAGE-----

On Wed, 04 Dec 1996 23:13:02 -0600, I wrote:
>
>A solution for Macs and PCs is certainly possible though. It will take
>more work because I haven't done any work with Python on Macs or PCs.
>I'll look into getting a solution going on a Mac, then on a PC running
>95/NT. Don't expect anything for a month or so, though.

OK, so I lied - an alpha version of a lpr client that runs on the
Macintosh is now available. It's a tribute to GvR and Jack Jansen that
Python and the Mac port of Python made this so easy. Would you believe
that this is my first Python script for the Mac?

Anyway, for the full details, see
<http://www.netins.net/showcase/jollie/python/lpr/>. I'd appreciate it
if folks would give it a whirl. I'd also appreciate it if those
familiar with Mac Python scripting would take a look at the
implementation of get_entry() and let me know what they think of
it. I'm sure that there's a more elegant way to implement this
function on a Mac, perhaps using resources.


[A copy of the headers and the PGP signature follow.]

Date: Thu, 05 Dec 1996 13:30:33 -0600


Newsgroups: comp.lang.python
Organization: netINS, Des Moines, IA, USA

References: <slrn459om0...@worf.netins.net> <Pine.LNX.3.91.961129...@ruby.gem.co.za> <slrn45aa1d...@worf.netins.net> <585558$r...@beast.connix.com> <slrn45acm...@worf.netins.net>
Subject: ANNOUNCE: Python LPR Library v0.1 (was: Re: lpd client in python)
To: python...@python.org

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

Comment: AnySign 1.4 - A Python tool for PGP signing e-mail and news.

iQCVAwUBMqci3pwkOQz8sbZFAQHTEwQA0M6L3SX3XxF2k/N3U9QIa9LzY0WJT1MM
B7F+e3tDnQmhoqTfm9zoU5QPJPbRe6xfMoBBPACf04hTH5N3UjeM/aimf7xWkmTJ
5muxnppF8kp14UMHO6/SDVo3+B8zIPvNW5v0+AwuX3cqv4vB7oUmM/qq6lc77e8L
XFmzLhDaUFc=
=8KlU

0 new messages