[mod.computers.masscomp] use your network and your printers better

sob@soma.UUCP (08/19/86)

nroff this with "nroff -ms file" --- enjoy, Stan
-------------------------------------------------------------------
.TL
Using the Masscomp Line Printer System with a Network
.AU
Stan Barber
.AI
Baylor College of Medicine
Houston, Texas
.AB
This paper describes a method of using the Masscomp Line Printer System
with ethernet to allow easy usage of printers not hardwired to the local
machine. This method does not require any modifications to the binary
software distributed by Masscomp.
.AE

.NH
Intoduction and Overview
.PP
Presented in the paper is an outline for adapting the Masscomp Line Printer
System (adapted from AT&T Unix System V) for use with the Masscomp ethernet
system (SP-70). If you are not familiar with the Line Printer System,
you might want to take a moment to read the section on the Line Printer
System in the
.I "System Management Guide."
You need to be familiar with the
.B lpadmin
command and the construction of printer interface programs to install
and/or modify this system for your needs.
.PP
In a nutshell, you will need to install new printer interface programs
on your machines without printers that need to use printers on machines
with printers. You will need to give all printer devices that are to be
accessed by remote machines a unique name (e.g. they all can't be called
"lp"). And, you may want to modify the printer interface program
on the machine to which the printer is attached.

.NH
Naming Your Printers
.PP
Give your printers descriptive names. If you have a laser printer, you
might want to name is "laser" or "imagen". A Diablo 630 could be called
"diablo". A basic line printer on a machine named "yoda" might also be
called "yoda". If your users have a hard time remembering the names,
you can build little command programs that are the same on all machines
that will do the remembering for them (e.g. 
.B xpr
command always outputs to the printer named "laser",
.B dpr
command always outputs to the printer named "diablo", etc.). You can also
tell them about the
.B lpstat
command that can remind them of the names. A shell script that can be
used to "remember" for your users is included in Appendix A (Thanks to
D A Gwyn for the program).

.NH
Installation of the New Printer Interface Programs
.PP
Now that you have a uniform naming convention for your printers, you
are ready to install the printer interface programs in the network
machines. The printer interface program for the network in in Appendix B.
Install this program in /usr/spool/lp/model/network on all machines that
you want to use printers on other machines.
.PP
You will need to use the
.B lpshut
program to shutdown the
.B lpsched
daemon that may be running. It is best to do all this as the "lp" adminstrator
(user id "lp" on Masscomp systems). Now you are ready to install the network
interface. Change directories to /usr/spool/lp/model and copy network into
a newfile that matches the hostname of one of the hosts that had printers
hardwired to it that you want to use on the network. Edit the file
and change SPOOLHOST to match the name of that host. Repeat this for as
many hosts as you need: one file for each host that has printer hardwired
to it.
.PP
Now you are ready to install the new intefaces. You will use the
.B lpadmin
command to do this. The form of the command you will use looks like this:
.br
lpadmin -v/dev/null -mhostname -pprintername
.br
.I printername
must match the printername of the printer on the host to which it is
attached.
.PP
Now you are ready to restart the scheduler. Use the
.B lpsched
command to do this. Your system should be usable at this point.

.NH
Options
.PP
You might want to take better advantage of your printer system on the
machine hosting the printers. You can do this by using the interface 
program provided in Appendix C. This is a generic interface. You will
have to customize it for any filters or accounting you might want to
do. It is similiar to the generic interface provided by Masscomp.

.NH
Closing Comments
.PP
Please send feedback to my network addresses:
.br
sob@rice.EDU
.br
sob@soma.UUCP
.br
I will fix bugs that are reported.
Good Luck!
.br
Stan Barber
.sp 5
UNIX is a registered trademark of AT&T.
MASSCOMP is a trademark of Masscomp.
Diablo and Ethernet are tradmarks of Xerox Corporation.
Imagen is a trademark of Imagen.
Yoda is a trademark of LucasFilm,Ltd.
.sp 2
This software is provided without warrenty of any kind. Stan Barber
may in no way be held responsible for the use of this software under
any circumstances. This software may be redistributed without cost
as long as this paper is included with the distribution.
.bp
.SH 
Appendix A -- lpr shell script
.PP
.sp 3
.nf
This is a replacement of the
.B lpr
command seen on most versions of UNIX.
.br
#!/bin/sh
#	lpr -- substitute for standard UNIX utility (BRL version)
#	last edit:	83/05/27	D A Gwyn
#	SCCSID	@(#)lpr.sh	1.2	edited 83/06/23 for 4.1cBSD
# PATH=/usr/3bin:/bin:/usr/bin:/usr/sbin

mflag=
rflag=false
for i in $*
do
	case $i in
	-c)	shift;;
	-m)	mflag=-m;	shift;;
	-n)	mflag=; 	shift;;
	-r)	rflag=true;	shift;;
	-*)	echo 'usage: xpr[ -cmnr][ file ...]';	exit 1;;
	*)	break;;
	esac
done

if [ $# = 0 ]
then
# change it here!
	 lp -dlaser $mflag -
else
	trap	"trap 0; \
		echo \"xpr: interrupted; possibly not spooled:\\n\\t\$*\"; \
		exit 2" 				0 1 2 3 15
#and here!
	if lp -c $mflag -dlaser -t$1 $*
	then
		trap 0

		if [ $rflag = true ]
		then
			rm -f $*
		fi
	fi
fi
.bp
.SH
Appendix B -- network printer interface
.PP
.sp 3
.nf
This is the interface program to run on the machines that need to
use printers across the network.
.br
# $Header: network,v 1.2 86/02/03 22:37:55 lp Exp $
# Network interface to allow remote printers to be
# used
# this is not sophisticated, but neither is the 
# SYSV lp software, Stan Barber
# $Log:	network,v $
# 
# Revision 1.2  86/02/03  22:37:55  lp
# Corrected bug in host
# 
# Revision 1.1  86/02/03  22:17:49  lp
# Initial revision
# 
# 

SPOOLHOST=soma
printer=`echo $0 |sed -e 's/^interface\///'`
host=`uuname -l`
jobid=$1
user=$2
title=$3
copies=$4
options=$5
shift; shift; shift; shift; shift
files="$*"
filename=/tmp/network$$
echo "lp -d$printer \c" > $filename
if test $title; then
	echo "-t$title \c" >> $filename
fi
if test $copies -gt 1; then
	echo "-n$copies \c" >> $filename
fi
echo "-ou$user -oj$jobid -oh$host - \c" >> $filename

cat $files | rsh $SPOOLHOST `cat $filename`
status= $?
rm $filename
exit $status
.bp
.SH 
Appendix C -- revised host printer interface
.PP
.sp 3
.nf
Following is the interface program to run on the host that
actually has the printer connected to it.
.br
# lp interface for generic line printer.
# suitable to modify for a local line printer.
#
#	$Header: generic,v 8.3 86/08/18 15:07:55 sob Exp $
#	$Log:	generic,v $
# Revision 8.3  86/08/18  15:07:55  sob
# Cleaned up the banner a bit
# 
# Revision 8.2  86/08/18  15:03:48  sob
# Added modifications for network system
# 
# Revision 8.1  86/08/18  14:52:07  sob
# 
#
#

jobid=$1
user=$2
title=$3
copies=$4
options=$5
host=`uuname -l`

# stty command could go here if needed

for j in $options
do
	case "$j" in
	
	u*)
		user=`echo $j |sed -e 's/^u//'`
		;;
	j*)
		jobid=`echo $j |sed -e 's/^j//'`
		;;
	h*)
		host=`echo $j |sed -e 's/^h//'`
	esac
done


banner "$user"
if [ -n "$title" ]
then
	banner "$title"
else
	banner stdin
	title= stdin
fi
banner "$host"
echo "\n"
echo "\t\t\tJob: $title ( $jobid ) \n"
echo "\t\t\tDate: \c"
date
echo "\n"
echo "\014\c"
shift; shift; shift; shift; shift
files="$*"
i=1
while [ $i -le $copies ]
do
	for file in $files
	do
		cat "$file" 2>&1
		echo "\014\c"
	done
	i=`expr $i + 1`
done
exit 0