[EdCert previous] [EdCert next] [EdCert top]

Printing under Unix

The printing systems under Unix basically comes in two flavors, the BSD spooling system that uses lpd daemon to schedule the print jobs, and the SVR4 spooling system that uses lpsched as the scheduler. Each of these systems will be discussed briefly.

BSD spooling system

BSD spooling system is not an elegant spooling system. However, it extends well to large, heterogeneous networks allowing many computers to share printers. Linux, SunOS, and Digital UNIX use basic BSD spooling system with minor changes and a few extensions. IRIX has an optional software which supports BSD style printing. HP-UX also supports BSD style lpr command even though it uses the SVR4 spooling system.

Under the BSD spooling system, access to printers is controlled by lpd daemon and the lpr program. lpr is the only program on a BSD system that can queue files for printing. Other programs such as enscript, ditroff etc., do so by calling lpr. lpr accepts data to be printed, puts it in a spooling directory, and notifies the lpd daemon. For each print job, lpr creates a control file (cfxxx) and a data file (dfxxx) in the spool directory, xxx indicating a unique job-id. The control file contains the information for handling the print job, including the identity of the owner. The data file contains the actual data to be printed.

The lpd daemon checks the /etc/printcap file to identify the destination printer. If the destination printer is a local device, lpd makes sure a copy of the lpd daemon is running on that print queue. Otherwise lpd opens a connection to the remote host to which the printer is connected and transfers both the control and data file to it.

Print jobs are scheduled by lpd on a First-In, First-Out (FIFO) basis. However, the system administrator may use the lpc command to alter the priority of the jobs in the print queue.

The printcap file

The BSD spooling system uses /etc/printcap as a database where each supported printer is defined. A printer definition consists of a number of entries, separated by ":", specifying the capabilities of the printer and how the print file is to be processed. Each entry within the printer definition specifies a set of variables, each identified by a two character variable name. A variable may be boolean, or may have a string or numeric value. A string value is assigned using the equal sign, the numeric value is assigned using the pound sign, and the presence of the boolean variable indicates the value 'true'. See the sample entries given below.

The first entry is the name of the printer and its aliases (if any), separated by "|". Other entries commonly found in the printcap file are:

lp=device-name
For a printer that is connected through a serial, parallel, or SCSI port, the device is the file in the /dev directory. If the printer is on a network, device-name may be a pointer to a null file.

sd=spool-directory
Each printer should have its own spool directory, usually in the /var/spool directory. Spooled files are stored in this directory until they can transmitted for printing.

lf=log-file
The same log file may be specified for all printers. The entry within the log would indicate the name of the printer causing the error. Communication problems with remote printers would also be reported in the log file.

rm=remote-machine:rp=remote-printer
The rm variable specifies the remote machine to which the print jobs are to be sent, and rp variable specifies the name of the printer on that machine.

af=accounting-file
An accounting information file may be specified by the af variable. The accounting file may only be specified on the machine where the printer lives, since the information is recorded when a job is printed.

mx#max-size
mx is a numeric variable and is used to specify the maximum size of the print file, in blocks. The default is zero (:mx#0) indicating no limit.

pw#page-width:pl#page-length
The numeric variables pw and pl may be used to specify the page width (in characters) and page length (in lines).

py#page-width:px#page-length
The numeric variables py and px may be used to specify the horizontal and vertical page size in pixels.

sf
Presence of this variable suppresses printing of burst page header.

You may find other variables and the use of the printcap database explained in the man pages for printcap.

A Sample printcap entry

Remote Printer

wccps | WCC-PostScript | WCC Machine Room:\
        :lp=:sd=/var/spool/wccps:lf=/usr/adm/lpd-errs:\
        :mx#0:\
        :rm=wcclaser.ucs.indiana.edu:\
        :rp=wcclaser:

Local Printer

edcert1 | EdCert-Pr1 | Unix EdCert Lab:\
        :lp=dev/edc:sd=/var/spool/edcert1:lf=/usr/adm/lpd_errs:\
        nc
:af=/usr/adm/edcert1.acct:\
        :if=/usr/local/bin/edcert1:\
        :pl#64:pw#80:px#300:py#300:\
        :br#9600:fc#0000010:fs#0000301

Command Interface

lpr
lpr queues the specified file for printing. If no file is specified, it reads from the standard input. Options that may be specified include printer, number of copies, processing and post-processing option.

lpq
The lpq program lists the job in the print queue.

lprm
The command lprm may be used to remove a print job from queue. The command options include the printer and job-id or user-name. If the user-name is specified all jobs for that user will be dequeued.

lpc
The command lpc is normally used interactively. It allows the super-user to start/stop the daemons, enable/disable queuing or printing jobs, and monitor the status of a printer. The subcommand help prints a short list of the commands that may be entered.

SVR4 spooling system

Solaris and HP-UX uses the SVR4 print services. SGI recognizes both the BSD and SVR4 command interfaces. SVR4 offers more control and flexibility. Unfortunately, it was not designed with network printing in mind. It is also a little more complicated to set up.

Under SVR4 spooling system, the lp command accepts the data to be printed, makes a copy of it in the spool directory associated with the destination. The destination consists of a printer name and an optional specification of a class to which the printer belongs. When the specified printer is busy the job is sent to another printer in the same class. The spool directory is normally /var/spool/lp/request/printer-name and the print file is given a unique name to identify both the job and the user.

Access to the printer is controlled by lpsched daemon. It picks up the jobs from the spool directory and sends them to appropriate destination when it becomes available. lpsched also keeps a log, usually in /usr/spool/lp/log. The log file would indicate any error in processing the print jobs, as well as the user-name,

Command Interface

lpsched/lpshut
lpsched is a daemon that moves the files from the spool directory to the appropriate print destination. lpsched can be started only by root. It creates the file /usr/spool/lp/SCHEDLOCK to make sure that only one copy of lpsched is running. If lpsched is stopped abnormally, SCHEDLOCK must be removed before restarting lpsched.
lpshut shuts down the print service. Jobs currently printing will be stopped and restarted when lpsched is restarted.

lp/cancel
Under SVR4 lp is the user level interface to queue data for printing. The destination is specified by the option -d. Various processing options are available for the lp command.
The cancel command cancels jobs queued or printing. All jobs belonging to a user, queued to a specified printer, or identified by the job-id may be canceled.

lpstat
The lpstat command displays the current status of the print service. If no options are given, lpstat will display the status of all print requests of the current user.

lpmove
The command lpmove may be used to move specified print jobs to a specific destination, or to move all jobs queued to dest1 to dest2. In the latter case, lp will reject any new request to dest1.

accept/reject
accept allows the queuing of print jobs for the specified printer or class of printers.
reject prevents queuing print jobs for the named destination. The reason for rejecting may be specified using -r option, and will be reported when the command lpstat -a is entered.

enable/disable
The enable command activates the specified printers, i.e., enables transfer jobs from spooler to the specified printer.
The disable command disallows moving jobs from spooler to the specified printer. The reason for disabling may be specified using -r option, and will be reported in response to lpstat -a.

lpadmin
The lpadmin command is used to configure the LP print service by defining printers and devices. It is used to add a printer, change the configuration of an existing printer, to remove a printer from service, and to set or change the default destination. Most SVR4 spooling system, expect Solaris, want lpsched to be shut down before lpadmin is used.
If a newly defined printer is causing problems to the lp spooling system, the best solution is to remove the destination completely, including all references to it within the spooling system, and start over.
For operating system specific extensions to the printing system, command interface and options and syntax of the commands, please consult the man pages for the appropriate operating system.

Interface Programs

Both BSD and SVR4 spooling systems support the concept of an interface program. The interface program, referred to as filters under the BSD system, is usually a shell script that translates the print file to a format suitable for the output device. The tasks performed by the interface program include: adding a banner and trailer pages, adding or removing a line feed character, generating accounting information and setting the correct modes on the output device. A standard interface program may be found in /usr/lib/lpf for the BSD systems and in /usr/spool/lp/model for the SVR4 system.

Using GUI for Printer Administration

Graphical User Interface tools, available on most platforms, makes the management of the printers and print queues less complicated.

On Solaris, enter the command admintool. From the Browse pull down menu select Printers to access the 'Print Manager'. The 'Print Manager' application allows you to install and set up printers on a system or on a network. For example, to add the remote printer 'buddy', select Add and Access to Printer, then enter:
Printer Name: buddy
Print Server: buddy.ucs.indiana.edu
Description: "WCC107 Hallway"

On HP-UX, enter the command sam to access the graphical interface to a menu-driven program that makes the system administration task easy. To access the printer administration task, select Printers and Plotters from the menu. The Actions menu has options to add, remove, enable and disable printers and other tasks. For example, to add the remote printer 'buddy', select Action, Add Remote Printers/Plotters and Remote Printer is on a BSD System then enter:
Printer Name: buddy
Remote System Name: buddy.ucs.indiana.edu
Remote Printer Name: buddy

On SGI, select from the window Toolchest, System and Print Manager. The basic printer management functionalities are available here. For example, to add the remote printer 'buddy', select Add and enter:
New Printer Name: buddy
Connection Type: network
Remote Host Name: buddy.ucs.indiana.edu
Remote Printer Name: buddy

Supplemental Reading


Terms used: spool, filter, printer class, dpi, pixel, PostScript




[EdCert previous] [EdCert next] [EdCert top]