[comp.unix.wizards] lp/lpr interface

drl%backup@uunet.uu.net (David R. Linn) (06/15/88)

Before I reinvent the wheel, can anyone provide pointers on interfacing
lpr- and lp-based spooling?  I have a network with both SUNOS/BSD machines
and HP-UX/SYSV machines and would like to be able to print from any machine
to any printer; that is, I would like to use lp(1) on an HP-UX machine to
print across our Ethernet to an Apple LaserWriter on a Sun machine and I
would also like to use lpr(1) to print from a Sun to a HPIB printer on
an HP machine.

+= David Linn ==========================================================+
|  System Manager, Vanderbilt University School of Engineering		|
|INET:	drl@vuse.vanderbilt.edu [129.59.100.1] (or root@vuse...)	|
|UUCP:	...!uunet!vuse!drl		CSNET:	drl@vanderbilt.csnet	|
|AT&T:	(615)322-7924			BITNET:	linndr@vuengvax		|
|USPS:	P.O. Box 1824, Vanderbilt University, Nashville, TN, USA, 37235	|
+======== "I can sing louder than you" - T. S. `Dr. Seuss' Geisel ======+
 

dewey@execu.UUCP (dewey henize) (06/15/88)

Regarding the lp/lpr connects, could you please pass on any info you get?
We have exactly the same problem coming up (if HP ever gets the Ethernet
connectors :-)

I tried to mail this, but our mailer isn't smart enough to handle the
path.  Sigh.

Dewey

-- 
===============================================================================
|      execu!dewey  Dewey Henize @ Execucom Systems Corp 512/346-3008         |
|    You don't think my employer APPROVES of these ideas, do you??  Sheesh!   |
=============================================================================== 

davidsen@steinmetz.ge.com (William E. Davidsen Jr) (06/16/88)

  The LP spooling as implemented in SysV (I haven't looked on SUNod but
I think it's the same) just executes a shell script with some arguments
defined and the file to be printed as stdin. I have a system setup to
use another systems printer, and the script uucp's the data to a special
directory on the machine with the printer. You can also do this by Enet,
and by allowing LPR in L.cmds so that it can be executed remotely. You
could cross mount directories if you have NFS.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

rbj@cmr.icst.nbs.gov (Root Boy Jim) (06/16/88)

? From: "David R. Linn" <drl%backup@uunet.uu.net>

Are you sure that address will work?

? Before I reinvent the wheel, can anyone provide pointers on interfacing
? lpr- and lp-based spooling?  I have a network with both SUNOS/BSD machines
? and HP-UX/SYSV machines and would like to be able to print from any machine
? to any printer; that is, I would like to use lp(1) on an HP-UX machine to
? print across our Ethernet to an Apple LaserWriter on a Sun machine and I
? would also like to use lpr(1) to print from a Sun to a HPIB printer on
? an HP machine.

Well, with BSD, at least you have source. Port lpr/lpd to the machines
that don't have it, and use the filter in lp to call lpr. Then pray.
I am assuming that all the networking code will work everywhere.

? += David Linn ==========================================================+
? |  System Manager, Vanderbilt University School of Engineering		|
? |INET:	drl@vuse.vanderbilt.edu [129.59.100.1] (or root@vuse...)	|
? |UUCP:	...!uunet!vuse!drl		CSNET:	drl@vanderbilt.csnet	|
? |AT&T:	(615)322-7924			BITNET:	linndr@vuengvax		|
? |USPS:	P.O. Box 1824, Vanderbilt University, Nashville, TN, USA, 37235	|
? +======== "I can sing louder than you" - T. S. `Dr. Seuss' Geisel ======+

Your signature is too wide. Please reformat it.

	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
	Careful with that VAX Eugene!

ray3rd@ssc-vax.UUCP (Ray E Saddler III) (06/17/88)

I also am interested in mixing and matching lp and lpr.  Please
post the results or mail copies.  Thank you very much.


-- 
| Ray E. Saddler III       |    __  __ __       __ |   Path: ..!ssc-vax!ray3rd |
| Boeing Aerospace         |   / / / //   //| //   | From: ray3rd@ssc-vax.UUCP |
| P.O. Box 3999 m.s. 3R-05 |  /-< / //-  // |// _  |---------------------------|
| Seattle, Wa.  98124  USA | /__//_//__ //  //__/  |  VoiceNet: (206) 657-2824 |

guy@gorodish.Sun.COM (Guy Harris) (06/17/88)

>   The LP spooling as implemented in SysV (I haven't looked on SUNod but
> I think it's the same)

More or less.  The SunOS spooler is the 4.2BSD or 4.3BSD spooler (4.3BSD if
you're running 4.0); it does have the notion of "filter" programs, but it's
done differently.  The 4.xBSD one also has networking support built in; it's
nice to have "lpq", "lprm", etc. work over the wire as well as "lpr"
(especially since I have no printer attached to my machine).

> I have a system setup to use another systems printer, and the script uucp's
> the data to a special directory on the machine with the printer. You can
> also do this by Enet,

If you have a UUCP that works over e.g. TCP on both sides; the current SunOS
one doesn't support TCP connections.

davidsen@steinmetz.ge.com (William E. Davidsen Jr) (06/18/88)

In article <56808@sun.uucp> guy@gorodish.Sun.COM (Guy Harris) writes:

| If you have a UUCP that works over e.g. TCP on both sides; the current SunOS
| one doesn't support TCP connections.

  But it does... no change in uucp is needed. My system has a device
which has the characteristic of reading the first line sent after an
open and doing a telnet connection to that machine. All it takes is an
L.sys line something like:
  machine Any ttyT16 9600 ttyT16 "" machine gin:--gin: uuxxx ord: yyy

and you get a connection to uucico coming in on the telnet socket, which
uucico can't tell from a serial connection. I *think* it can be done
without a special device if your system allows you to write your own
dialer, but I haven't felt the need to try it.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

guy@gorodish.Sun.COM (Guy Harris) (06/18/88)

>   My system has a device...

But if you *don't* have such a device, and you don't have a UUCP that can
directly open TCP connections, you're out of luck.

andrew@riddle.UUCP (Andrew Beattie) (06/20/88)

In article <16162@brl-adm.ARPA> drl%backup@uunet.uu.net (David R. Linn) writes:
>Before I reinvent the wheel, can anyone provide pointers on interfacing
>lpr- and lp-based spooling?  I have a network with both SUNOS/BSD machines
>and HP-UX/SYSV machines and would like to be able to print from any machine
>to any printer;

This is the script that I use to set up the printers here.
It goes round all our computers and sets up all the spoolers so that anyone
can print on any printer from anywhere (good eh?)

Some notes:

This copy has had some site specific stuff hacked out of it (our interface 
scripts are actualy split into several parts and need special handling) and 
so has't been tested in exactly this form.

The directory that the script is run from should contain the printer interface
models. (in our case these are called draft and laser)

In order to cope with different printer speeds, the interfaces should contain
SPEED=set_this_at_installation
stty $SPEED ........etc

I havn't got shar to hand so convert this to a shell script simply by removing
the X at the begining of each line and cutting at the CUT HERE line

To configure for your network, you will need to change the value of ALLMACHINES
to all the sysV machines on your net and the table at the top of the script to
indicate which printers are on which machine.  

I have not included the draft and laser interface script, but I have included
the network transfer script.  This script must also be in the same directory 
and named tcp.

We have only one BSD machine and I interface it by having a script called *lp*
which does:

su guest_account -c "remsh sys_V_server_machine lp $*"

Script starts here:
---------------------------------------------------------------------------
X# ALL MACHINES NOT TO INCLUDE BSD MACHINES 
XALLMACHINES="amachine bmachine cmachine dmachine emachine fmachine"
Xtmpconf=/tmp/prconf$$
Xcat >$tmpconf <<!
X1printer	amachine	tty1a	laser	4800
X2printer	bmachine	tty8d	laser	9600
X3printer	cmachine	tty15	draft
X4printer	dmachine	tty8b	draft
X5printer	emachine	tty8c	laser	9600
X6printer	fmachine	tty43	laser	19200
X7printer	gmachine	tty9f	laser	9600
X!
X 
Xfor target in $ALLMACHINES
Xdo
X	echo purging spooler on ${target}
X	remsh ${target} /usr/lib/lpshut
X	remsh ${target} lpstat -o "|" cut "-d\ " -f1 "|" sed 's/\^/cancel\ /' \
X">" /tmp/clearup$$
X	for printer in `remsh ${target} lpstat -a |cut "-d " -f1`
X	do
X		# remsh ${target} /usr/lib/lpadmin -x${printer}
X		remsh ${target} rm -rf /usr/spool/lp/interface/${printer} \
X/usr/spool/lp/member/${printer} /usr/spool/lp/request/${printer}
X	done
X	remsh ${target} cat /dev/null ">" default
X	remsh ${target} cat /dev/null ">" pstatus      
X	remsh ${target} cat /dev/null ">" log
X	remsh ${target} cat /dev/null ">" qstatus
X	remsh ${target} cat /dev/null ">" seqfile
X	remsh ${target} cat /dev/null ">" outputq      
X
X	for printer in `cut -f1 $tmpconf`
X	do
X		echo creating the printer ${printer} on ${target}
X		set -- `grep "^$printer	" $tmpconf`
X		remsh $target chmod 600 /dev/$3
X		remsh $target chown lp /dev/$3
X		model=$4
X		if [ $2 != $target ]
X		then
X			sed "s/^SERVER=.*/SERVER=$2/" <tcp >/tmp/tcp$$
X			rcp /tmp/tcp$$ ${target}:/usr/spool/lp/model/temp
X			remsh ${target} /usr/lib/lpadmin -p$printer \
X-v/dev/null -mtemp
X		else
X			rcp $model ${target}:/usr/spool/lp/model/temp
X			remsh ${target} /usr/lib/lpadmin -p$printer \
X-v/dev/$3 -mtemp
X		fi
X		remsh ${target} enable ${printer}
X		remsh ${target} /usr/lib/accept ${printer}
X	done
X	# remsh ${target} /usr/lib/lpsched "<" /dev/null
Xdone
X ----------- CUT HERE ---------------
X# this script is called tcp
XERR="lp remote print spooler failure: contact administrator" 
XSERVER=support				# Name of target machine
X
XPRINTER=`basename $0`
XBANNER="${3:-$2}"
XCOPIES=$4
Xfor I in $5
Xdo
X	OPTIONS="$OPTIONS -o$I"
Xdone
Xshift; shift; shift; shift; shift
Xfor I
Xdo
X        if echo $I | grep "/usr/spool/lp" > /dev/null 2>&1
X	then
X		chmod a+r $I
X		while :
X		do
X			# this should use rcp ... but never mind
X			if cat $I | remsh ${SERVER} lp -d$PRINTER \
X"-t$BANNER" "-n$COPIES" "$OPTIONS" -
X			then 
X				exit 0
X			else
X				sleep 60
X			fi
X		done
X
X
X
X        fi
Xdone

Andrew Beattie
Sphinx, 43-53 Moorbrige Road, Maidenhead, England
mcvax!ukc!reading!riddle!andrew
andrew@sphinx.co.uk
+44 628 75343
#include <disclaimer.h>

rbj@cmr.icst.nbs.gov (Root Boy Jim) (07/02/88)

? In article <16196@brl-adm.ARPA> you write:
? >? From: "David R. Linn" <drl%backup@uunet.uu.net>
? >
? >Are you sure that address will work?
? >
? >? Before I reinvent the wheel, can anyone provide pointers on interfacing
? >? lpr- and lp-based spooling?  I have a network with both SUNOS/BSD machines
? >? and HP-UX/SYSV machines and would like to be able to print from any machine
? >? to any printer; that is, I would like to use lp(1) on an HP-UX machine to
? >? print across our Ethernet to an Apple LaserWriter on a Sun machine and I
? >? would also like to use lpr(1) to print from a Sun to a HPIB printer on
? >? an HP machine.
? >
? >Well, with BSD, at least you have source.
? 
? I don't understand this comment.  Please amplify?

Exactly what I said. He might need the source to port to a machine that
has internet support, but not lpr/lpd, which I can't imagine, but might
conceivably exist. For example, AIX does have some internet support, but
since it is System V based, might use lp rather than lpr.
 
? >Port lpr/lpd to the machines
? >that don't have it, and use the filter in lp to call lpr. Then pray.
? >I am assuming that all the networking code will work everywhere.
? 
? We set up our system V machines to do uux to a "print server", a
? BSD machine that knew how to get to all the printers.  It works
? fine.  No porting required.

Good move. Since I intent to remain adamantly ignorant of uucp (I suppose
I should modify my opinions a bit, but am spoiled by the internet), I
didn't even think of that.

? I have one machine that runs BSD and SYSV concurrently.  It has
? both lp and lpr, but I didn't want both deamons talking to the
? same device at the same time.  Hacking the interface script in
? the lp command to pipe through lpr solved the problem.

Isn't that what I said above?

? 			Ron

	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
	Careful with that VAX Eugene!
..  I think I'll KILL myself by leaping out of this
 14th STOREY WINDOW while reading ERICA JONG'S poetry!!