HDS ViewStation System Administrator's Guide

A Hypertext Document


LP Print Service Network Printing

This page discusses using the ViewStation for LP Print Service network printing.

The LP Print Service for UNIX System V Printing

Printing with the ViewStation on UNIX System V computers uses a slightly different process and different files, but the procedure is very similar to LPD Print Spooler operation. Descriptions and sample files for LP Print Service are distributed with HDSware software (Version 3.0.3 or higher) in the /hds-fx/config/lp-support directory.

Using LP Print Service with the ViewStation
HDS has generated a sample printer model that lets you take advantage of the local printing capability of the ViewStation. Printing is generally a system-wide function, so this file will have to be modified or adapted to your particular situation. This printer model is intended as a sample only.

Your system may be different, use different commands or syntax, so you will have to make the necessary adjustments.

On UNIX System V systems, printing support is handled by the LP print service. The shell command to print a file is usually "lp". The LP print service is responsible for opening the path to the printer requested, passing the file through various filters, maintaining the print queue, etc.

The LP print service supports both local and remote printers. If a printer is a remote printer, then the print file is sent to the remote printer host's print service. 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 LP print service 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 a new printer model to the controlling host's lp/model directory.

Sample Printer Model File
A sample printer model file entry, hds-model.sh, is included in this /hds-fx/config/ lp-support directory.

The key to making this arrangement work is the use of a printer model, such as the hds-model.sh file included in this directory. This HDS printer model is specified in the "lpadmin" command when adding a new printer or modifying an existing printer. When printing a file, the LP print service calls the HDS printer model script with multiple arguments, including the file names to print. The HDS printer model calls the normal printer model (configured by the user) and captures the output. This output is then transferred to the ViewStation via remote shell execution of an "opendev" task. The HDS printer model logs any errors generated to the standard error channel.

The sample printer model included in this directory, "hds-model.sh", 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 ViewStation, you will have to create separate printer model entries for each printer.

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 LP process executing the printer model script 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 print spooler administration tools on the controlling host.

Adding a ViewStation Printer to the LP Print Service
Follow these steps to add a ViewStation printer to your LP Print Service.

Attach the printer to the desired ViewStation's serial or parallel port. If using a serial printer, make sure the communications settings and cable are correct.

Make sure there is a host name corresponding to the ViewStation's IP address in the host's IP database. (For example, /etc/hosts)

Choose a name for the printer. This probably should be the same as the host name of the ViewStation, but need not be. For example, your ViewStation name might be: hdsfx1

Copy and rename the hds-model.sh script to the lp/model directory. There should be a separate copy and name for each ViewStation printer. Set the owner and execute permission on each model script.
<path> is the path to the lp/model directory, usually /usr/spool/lp/model
cp hds-model.sh <path>/<printername>
cd <path>
chown lp <printername>
chmod +x <printername>


For example:

cp hds-model.sh /usr/spool/lp/model/hdsfx1
cd /usr/spool/lp/model
chown lp hdsfx1
chmod +x hdsfx1


Set the X terminal name (XTERM), the parallel or serial port (DEV), and the printer model (MODEL) variables for the printer in each of the model scripts. Also set the path to the remote shell command (RSH_CMD) and whether or not NEWLINE characters should be replaced with CARRIAGE RETURN / NEW LINE characters (NFILTER). All of these configurations are at the beginning of the model script.

For example:
RSH_CMD=/usr/bin/remsh
DEV=/dev/pp0
XTERM=mshfx
MODEL=/usr/spool/lp/model/HPDeskJet500
NFILTER="cat -"


Add the printer with the `lpadmin' command. Specify the printer device as `/dev/null' using the `-v' option. Specify the model as <printername> using the `-m' option. Specify the printer as printername> using the `-p' option. Also specify any other desired options, such as `-o nobanner'.

Check the `lpadmin' manual page for supported options and meanings, as well as spacing and syntax. For example:
/usr/lib/lpadmin -p hdsfx1 -v /dev/null -m hdsfx1

Start the new printer with the "accept" and "enable" commands. For example:
accept hdsfx1
enable hdsfx1


Print some test files to the printer. For example:
lp -d hdsfx1 /etc/motd

You can monitor the printing with the ViewStation's local Console `ports' command.

HDS-Model File
This is a copy of the hds-model.sh file.

#!/bin/sh
#####
# hds-model.sh: Sample model file for use with System V printing
# facilities to allow ``lp'' to print to a device connected to an
# HDS ViewStation's parallel or serial ports.
# This script is a wrapper that calls the normal printer `model'
# script and then sends the output to the ViewStation.
#####
# Copyright (C) 1994 HDS Network Systems, Inc. All rights
# reserved.
# ident: SCCSID = "@(#)hds-model.sh 1.1 6/9/94"
#####
PATH=/bin:/usr/bin:/usr/etc; export PATH
TMP=/tmp
OPENDEV=opendev
#RSH_CMD=/usr/bin/rsh
RSH_CMD=/usr/bin/remsh
#####
# Set DEV=/dev/pp0 (parallel port)
# DEV=/dev/tty1 (serial port 1)
# DEV=/dev/tty2 (serial port 2)
# for ViewStation FX;
#
# Set DEV=printer
# for older ViewStation
#####
DEV=/dev/pp0
#####
# Set the X terminal name.
# XTERM=<ViewStation hostname>, or XTERM=<ViewStation IP address>
#####
XTERM=mshfx
#####
# Set MODEL equal to the path of the normal model script for the
# printer, e.g. MODEL=/usr/spool/lp/model/HPDeskJet500. MAKE SURE
# THE MODEL FILE ie. HPDeskJet500 is executible by everyone
#####
MODEL=/usr/spool/lp/model/standard
NFILTER="cat -"
#####
# Uncomment the next line to map NEWLINE characters
# to RETURN-NEWLINE.
#####
#NFILTER="sed -e s/$/^M/g"
#####
# Get arguments passed to this script and save away to reconstruct
# them when calling the `MODEL' script.
#####
PROG=$0
ARG1=$1
ARG2=$2
ARG3=$3
ARG4=$4
ARG5=$5
shift 5
FILES=$*
ABORT=2
name=unknown
host=unknown
#####
# 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
$MODEL "$ARG1" "$ARG2" "$ARG3" "$ARG4" "$ARG5" $FILES | ${NFILTER} > $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

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.