HDS ViewStation System Administrator's Guide

A Hypertext Document


LPD Print Spooler for BSD Systems

This page describes using the ViewStation with an LPD Print Spooler.

The LPD Print Spooler for BSD Systems
HDS has generated a sample print spooler that lets you take advantage of the local printing capability of the ViewStation. Printing is generally a system-wide function, so these files will have to be modified or adapted to your particular situation. This print spooler is intended as a sample only. Your system may be different, or use different commands or syntax, so you will have to make the necessary adjustments.

LPD Daemon
On BSD UNIX systems, print spooling is handled by a daemon process known as LPD. The shell command to print a file is usually "lp" or "lpr", which sends messages to the LPD daemon indicating the names of the files to print, the number of copies, etc. The LPD daemon process is then responsible for opening the path to the printer requested, passing the file through various filters, maintaining the print queue, etc.

The LPD process is started by the system administrator. At startup, it reads a file called /etc/printcap which lists the printers available to the LPD daemon and whether those printers are local or remote. If the printer is a remote printer, then transfering the print file also involves the LPD on the local host communicating with the remote host's LPD. In this case, the remote host is responsible for temporarily storing the print file in its local file system until it can be sent to the printer.

Since the HDS ViewStation may not have any local disk memory for this temporary storage, one host's LPD should store and maintain the print job queues for the printer attached to the ViewStation. To make this arrangement, the system administrator should configure the ViewStation's printer as if it were locally connected to that controlling host. This is done by adding an entry into the controlling host's /etc/printcap file. A sample printcap file entry is included in this LPD directory.

The key to making this arrangement work is the use of an input filter, such as the hds-spool.sh file included in this directory. This input filter is specified in the /etc/printcap file as "if=<filter pathname>". The LPD daemon writes the contents of the print file to the standard input of this filter. The filter then performs several tasks; it opens a remote shell on the ViewStation and transfers the print file to an "opendev" task, which routes the data to the device specified on the opendev command line. It also logs any errors generated to the filter's standard error channel and appends them to the log file (which was specified in the /etc/printcap entry "lf=<log file pathname>".

On a system with multiple ViewStations, you would make a copy of the input filter, hds-spool.sh, each with its own name and variables, for each ViewStation. Each ViewStation would also have its own printcap file.

Sample Input Filter File
The sample input filter is shown below. The script is "hds-spool.sh" and is written as a Bourne shell script, which may be customized as needed. As it appears here, it is hardcoded to send its output to a specific ViewStation hostname (or IP address) and to a specific hardware port. (The ViewStation can connect to printers on its parallel port or to printers on its two serial ports.) If you want to set up a system with a single host controlling printers connected to more than one View Station, you will have to create separate /etc/printcap entries for each printer, and the input filter script specified for each printer must be modified so it connects to the correct ViewStation and hardware port on the ViewStation.

Note that the ViewStation will not abort the print job if the printer is off-line or out-of-paper. Instead, the ViewStation will stop accepting data on its "shell" TCP port, which in turn will cause the lpd process executing the input filter shell on the controlling host to block until the ViewStation resumes accepting data. Print jobs may be aborted either by "killing" the opendev process on the ViewStation, or by using "lpc" or other print spooler administration tool on the controlling host.

Spooler Shell Script
This is the hds-spool.sh script. It is written as a Bourne shell script to let the host's LPD process to write to an HDS ViewStation. It is a sample input filter which you need to customize. Each ViewStation with a printer should have one of these files with its variables set appropriately.

# !/bin/sh
# hds-spool.sh: Sample input filter to allow lpd to print to
# an HDS ViewStation
# Copyright 1992, 1993, 1994 HDS Network Systems, Inc.
# All rights reserved.
# SCCSID = "@(#)hds-spool.sh 1.3 6/22/93"
PATH=/bin:/usr/bin:/usr/etc:/usr/ucb; export PATH
TMP=/tmp
PROG=$0
OPENDEV=opendev
# Set RSH_CMD as needed for your system (RSH, RCMD, or REMSH, etc.)
RSH_CMD=/usr/ucb/rsh
# Set DEV=/dev/pp0, DEV=/dev/tty1, or DEV=/dev/tty2 for
# ViewStation FX models;
# Set DEV=printer for older ViewStation models DEV=/dev/pp0
# Set xterm=<hostname of ViewStation>
xterm=hdsfx
ABORT=2
name=unknown
host=unknown
while [ $# -gt 0 ]
do
case "$1" in
-w*)
;;
-l*)
;;
-i*)
;;
-n)
if [ $# -gt 1 ]
then
shift
name="$1"
fi
;;
-h)
if [ $# -gt 1 ]
then

shift
host="$1"
fi
;;
-*)
echo $PROG: Filter flag $1 not supported. >&2
exit $ABORT
;;
esac
shift
done
# Extract base name of this shell program
OLDIFS="$IFS"
IFS=/
set $PROG
IFS="$OLDIFS"
PROG=`eval echo \\\$$#`
status=0
trap "rm -f $TMP/tfile$$; rm -f $TMP/tlog$$; exit \$status" 0
cat - > $TMP/tfile$$
status=0
finished=0
while [ "$finished" -eq 0 ]
do
$RSH_CMD $xterm $OPENDEV $DEV < $TMP/tfile$$ > $TMP
/tlog$$ 2>&1
status=$?
if fgrep `opendev' $TMP/tlog$$ > /dev/null
then
if fgrep `EBUSY' $TMP/tlog$$ > /dev/null
then
sleep 10
else
echo "`date` $PROG: `fgrep `opendev' $TMP/
tlog$$`" >&2
status=$ABORT
fi
else
finished=1
fi
if [ "$status" -gt 0 ]
then
status=$ABORT
finished=1
echo "`date` $PROG: Aborted print job for ${name}@${host}">&2
fi
done
exit $status


Printcap File
This is a sample printcap file. You need to customize this for your environment.
#
# This is a sample of printcap entries used to print to HDS
# ViewStations.
#
# The spool directory must be created in /usr/spool/, and you
# must also "touch" the "lp" file for each printer attached
# to a ViewStation. The "lp" file is used simply to lock each
# printer during printing. The input filter "if" must be
# unique for each separate printer, since it specifies which
# ViewStation to print to. You could get fancy and embed the
# ViewStation name in the input filter name, and use links to
# a single input filter, but this seems overkill unless you
# plan to support very many printers connected to
# ViewStations.
#
# SCCSID = "@(#)printcap 1.2 6/22/93"
#
1|hdsVS-1|Test of printer spooler to HDS ViewStation:\
:sd=/usr/spool/hdsVS:lf=/usr/adm/lpd-errs:\
:if=/usr/local/bin/hds-spool.sh:\
:sh:lp=/dev/hdsVS-1:
#


There are several things to note:

The "hdsVS-1" on the first line is the network name of the printer. It is the destination name you give for your print job. It should probably be the printer name (such as PS, or LJ) rather than a name associated with the ViewStation, unless there are multiple printers of that type connected to ViewStations.

The ":sd" entry is the spool directory and contains the printer's filter file /usr/spool/hdsVS; again, its name should reflect the printer name or type rather than the ViewStation name.

The ":lp" entry on the last line is the network name of the printer. This line acts as a "lock" mechanism to see if the device is currently in use. You have to create this file with the "touch" command when you add this entry to your printcap file (do "touch /dev/hdsVS-1").

The ":if" entry is the input filter path and name for the ViewStation's input filter, which specifies the ViewStation's name and the port for the printer connection. Make sure this path and name are correct for each ViewStation and printer.

The file reads as if it were a single line, so use the backslash characters to end lines. The ":" character separates the variables and their values from each other.

ViewStation Print Spooler Example

The following example shows how these files should be customized for a ViewStation printing on a network. Both the input filter file and the printcap file need to be modified.

Modifying the Input Filter File
1. You must have a separate input filter file for each ViewStation with a printer, or even a separate file for each port used for printing on a single ViewStation. Name these files in a way convenient for your system, such as:
hds64-spool.sh
hds65-spool.sh


2. Enter the ViewStation's name (not IP address) as the "xterm" variable.

3. Enter the ViewStation's printer port as the "DEV" variable.

4. If necessary, change the RSH_CMD command line to reflect your system's remote shell command (rcmd for SCO systems, for instance).

Modifying the Printcap File
You must make an entry in your printcap file (usually /etc/printcap) for each network printer. You must make these changes to the sample printcap entry:

1. Enter the network printer name for the printer attached to the ViewStation.

2. Enter the input filter filename and path you created for the ViewStation on the "if=" line in the printcap entry.

Sample Printcap File
If your ViewStation's name was "nancyfx", you wanted the printer's network name to be "HP-LJ", and you had named the input file with the nancyfx settings in it "hds65-spool.sh", you would make these modifications to the printcap entry.

1|HP-LJ|Test of printer spooler to HP-LJ on ViewStation65:\
:sd=/usr/spool/HP-LJ:lf=/usr/adm/lpd-errs:\
:if=/usr/local/bin/hds65-spool.sh:\
:sh:lp=/dev/HP-LJ:


The hds65-spool.sh script would have variables "DEV=/dev/pp0" and "xterm= nancyfx" set.

Add this entry to your /etc/printcap file with other network printer entries. Remember to create the :lp file (by "touch /dev/HP-LJ") when you add the entry.

Return to Section Heading Page


Return to the Home Page

If you need more information than is available here, you can reach HDS via email at info@hds.com, or call us at 1.800.HDS.1551 in the USA, or at +610.277.8300 from outside the US. For questions or problems regarding the HDS WWW page, contact webmaster@hds.com.
© 1996 by HDS Network Systems Inc.