[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Guide to Printers and Printing

Understanding the Print Service

The UNIX system print service is a collection of utilities that help you, as system administrator (or printer administrator), to configure, monitor, and control the printers on your system.

The print service:

When a user sends a file to a printer, the print service assigns to the request (print job) a unique name, the request ID.

The request ID consists of the name of the printer on which the file is to be printed and a unique number identifying the file. Use this request ID to find out the status of the print job or to cancel the print job. The print service keeps track of all the print requests in the request log.

The print job is spooled, or lined up, with other print jobs to be sent to a printer. Each print job is processed and waits its turn in line to be printed. This line of pending print jobs is called a print queue.

Each printer has its own queue; you can hold jobs in the queue, move jobs up in a queue, or transfer jobs to another queue.

Overview of Print Request Processing

The following figure provides an overview of the processing of a print request.

Figure 6-1. Overview of Print Request Processing

Figure print11 not displayed.

Each print request is sent to a spooling daemon (background program) that keeps track of all the jobs. (This information is archived in the request log.) The daemon is created when you start the print service. The spooling daemon is also responsible for keeping track of the status of the printers and slow filters; when a printer finishes printing a job, the daemon starts it printing another job if one is queued.

You can customize the print service by adjusting or replacing some of the items shown in the Overview of Print Request Processing figure (the numbers are keyed to the diagram).

  1. Print service configuration: For most printers, you need only change the printer configuration stored on disk. See the lpadmin command for adding or modifying a local printer.
  2. terminfo database: For printers that are not represented in the terminfo database, you can add a new entry that describes the capabilities of the printer. See Adding a Printer Entry to the terminfo Database. The print service uses the terminfo database in two parallel capacities: screening print requests to ensure that those accepted can be handled by the desired printer, and setting the printer so it is ready to print the requests.

    For instance, if the terminfo database does not show a printer capable of setting a page length requested by a user, the spooling daemon rejects the request. However, if it does show it to be capable, then the interface program uses the same information to initialize the printer.

  3. Standard Interface Program: If you have a particularly complicated printer or if you want to use features not provided by the print service, you can change the interface script. This script is responsible for managing the printer: it prints the banner page, initializes the printer, and invokes a filter to send copies of the user's files to the printer.
  4. Optional filters: To provide a link between the applications used on your system and the printers, you can add slow and fast filters. Each type of filter can convert a file into another form, for example, mapping one set of escape sequences into another, and can provide a special setup by interpreting print modes requested by a user. Slow filters are run separately by the spooling daemon to avoid tying up a printer. Fast filters are run so their output goes directly to the printer; thus, they can exert control over the printer.

About the Print Request Log

Each time a user sends a job to the printer, the print service creates two files that describe the job request and places one each in the /usr/spool/lp/temp and /usr/spool/lp/requests directories. The information about the job is split into two files so that the system can keep sensitive information secure in the /usr/spool/lp/requests directory. The user who submitted the job has access to the request file in /usr/spool/lp/temp; only the printer administrator (or root user) has access to the file in /usr/spool/lp/requests.

The request files remain in these directories only while the job is in the queue. When the job finishes printing, the information in the two files is combined and appended to the request log, /usr/spool/lp/logs/requests.

The structure of the request log makes it easy to extract data using common UNIX shell commands. The requests are listed in the order in which they were printed, separated by lines that begin with the request ID. Each line below the separator line is marked with a single letter, the request log code, that identifies the kind of information contained in the line. Each letter is separated from the data by a single space. The table following the sample entry describes these codes.

Following is a sample entry from the print request log:

   = ps-717, uid 1532, gid 18, size 7872, Tue May 10 14:43:10 1994
   z ps
   C 1
   D ps
   F /usr/spool/lp/temp/717-1
   P 20
   t simple
   U hanna
   s 0x0010

Request Log Entries Table:

Letter Content of line
= The separator line lists the (comma-separated) request ID, user ID (uid), and group ID (gid) of the user who submitted the request, total number of bytes in the original (unfiltered) file (size), and the date and time the request was queued.
C Number of copies printed.
D Printer or class destination or the word any.
F Name of the file in the /usr/spool/lp/temp directory. This line is repeated for each file printed, and files are printed in the order given.
f Form name used (if applicable).
H Type of special handling used:
  • resume
  • hold
  • immediate
N How the print service notified the user after printing the file (if applicable):
  • M   by an electronic mail message
  • W   by a message written to the user's terminal
O Any -o options given to the lp command.
P Priority of the print request, if applicable.
p List of pages printed.
r Any -r options given to the lp command indicating that the user requested raw processing of the file.
S Character set used.
s Outcome of the job, expressed as a combination of individual bits in hexadecimal form. The important bits used internally by the spooler are:
  • 0x0004   Slow filtering finished successfully.
  • 0x0010   Printing finished successfully.
  • 0x0040   Request was canceled.
  • 0x0100   Request failed filtering or printing.
T Title on the banner page.
t Content type of the file.
U Name of the user who submitted the print request.
x Slow filter.
Y List of special modes to give to the filters used to print the request.
y Fast filter.
z Printer used for the request. This differs from the destination (the D line) if the request was queued for any printer or a class of printers, or if the printer administrator transferred the request to another printer.

Print Service Command Line Summary

In general, you should use Web-based System Manager to manage your print service. However, if you need to manage your print service from the command line, refer to these articles:

Print Service Commands Available to All Users Table:

Command Description
cancel Cancels a request for a file to be printed
lp Sends a file or files to a printer
lpstat Reports the status of the print service

The administrator can give users the ability to disable and enable a printer so that if a printer is malfunctioning, the user can turn the printer off without having to call the administrator. (However, in your printing environment, it might not be reasonable to allow regular users to disable a printer.)

The Administrative Print Service Commands Table lists print service commands available only to the administrator. To use the administrative commands, you must be logged in as root user.

The administrative print service commands are located in the /usr/lib directory. If you use these commands frequently, include /usr/lib in your PATH variable.

Administrative Print Service Commands

Command Description
Permits jobs to be queued for a specified destination
Prevents jobs from being queued for a specified destination
cancel Cancels requests to a line printer
Activates the named printers
lpadmin Sets up or changes printer configurations
lpc Provides (BSD) line printer control
lpfilter Sets up or changes filter definitions
lpforms Sets up or changes preprinted forms (use /usr/sbin/lpadmin to mount a form)
lpmove Moves output requests from one destination to another
Starts the print service
Stops the print service
lpsystem Registers remote systems with the print service
lpusers Sets or changes the default priority and priority limits that the users of the print service can request

The accept, reject, cancel, enable, disable, and lpadmin commands can also be run from the Web-based System Manager interface. To run these commands, start Web-based System Manager, then select the Printers plug-in from the Contents Area.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]