Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!oberon!bbn!uwmcsd1!marque!uunet!mcvax!ukc!reading!onion!riddle!andrew From: andrew@riddle.UUCP (Andrew Beattie) Newsgroups: comp.unix.wizards Subject: Re: lp/lpr interface Message-ID: <601@riddle.UUCP> Date: 20 Jun 88 08:07:57 GMT References: <16162@brl-adm.ARPA> Reply-To: andrew@riddle.UUCP (Andrew Beattie) Organization: Sphinx Ltd., Maidenhead, England Lines: 137 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 <" /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/"/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