Understanding the Structure of the LP Print Service
The following sections explain the structure and directory hierarchy for the LP print service. The many files of the LP print service are distributed among several directories, as shown in Table 88.
Table 88. Directories for the LP Print Service
The lp, lpstat, enable, and disable commands.
A hierarchy of LP configuration files.
The terminfo database directory.
The accept, reject, lpadmin, lpfilter, lpforms, lpmove, lpshut, lpsystems, and lpusers LP commands.
The LP daemons, directories for binary files and PostScript filters, and the model directory (which contains the standard printer interface program).
The logs for LP activities.
Messages from lpsched.
The spooling directory in which files are queued for printing.
Information about completed print requests.
The /usr/bin directory contains the lp and lpstat commands, with which users submit and monitor print requests. The directory also contains the enable and disable commands used to enable and disable printers.
Users can customize their print requests by using options for the lp command, specifying forms, character sets, filters, titles, banners, and so forth. Table 89 summarizes the frequently used options for the lp command. These options can be used individually or combined in any order on the command line. When combining options, use a space between options and repeat the dash (-). For example, the following command specifies a destination printer, requests e-mail notification, and prints six copies of a file.
% lp -d printer-name -m -n6 filename
Table 89. Summary of Frequently Used lp Options
Specify a destination printer by name.
Send e-mail to the user who submitted the print request when the file has been printed successfully.
Specify the number of copies to be printed.
Specify a title for a print request (printed only on the banner page).
Suppress printing of the banner page for an individual request.
Put a header on each page of the print request.
Copy the file before printing.
Write a message to root's terminal when the file has printed successfully.
See the lp(1) manual page for a complete list of options.
LP Configuration Files
The scheduler stores configuration information in LP configuration files located in the /etc/lp directory. You can check the contents of these files, but you should not edit them directly. The LP administrative commands provide input for the configuration files in the /etc/lp directory. The lpsched daemon administers and updates the configuration files. You should use the administrative commands any time you need to update any configuration file. Table 90 describes the contents of the /etc/lp directory.
Table 90. Contents of the /etc/lp Directory
Contains form, jobdone, printer, and sendMsg scripts for sending print system alerts to users.
Contains files that identify classes provided by the lpadmin -c command.
Contains descriptions of existing filters.
Is the location in which to put files for each form. Initially, this directory is empty.
Contains printer interface program files.
Link to /var/lp/logs
Contains log files of printing activities.
Link to /usr/lib/lp/model
Contains the standard printer interface program.
Contains directories for each (remote or local) printer setup. Each directory contains configuration information and alert files for an individual printer.
Contains print wheel or cartridge files.
The printers directory has a subdirectory for each printer (local or remote) known to the system. The following example shows the subdirectories for the printers pinecone and sparc1.
% ls -l /etc/lp/printers
drwxrwxr-x 2 lp lp 512 Jan 23 23:53 pinecone
drwxrwxr-x 2 lp lp 512 Jan 11 17:50 sparc1
Within each of the printer-specific directories, the following files can describe the printer.
alert.sh— Shell to execute in response to alerts.
alert.vars— Alert variables.
configuration— Configuration file.
users.deny— List of users who are denied printer access.
comment— Printer description.
The following example shows a typical configuration file for the printer pinecone, /etc/lp/printers/pinecone/configuration.
Banner: on: Always
Content types: PS
Printer type: PS
The LP print service uses the terminfo database to initialize a local printer; to establish a selected page size, character pitch, line pitch, and character set; and to communicate the sequence of codes to a printer. The terminfo database directory is located in /usr/share/lib.
Each printer is identified in the terminfo database with a short name. If necessary, you can add entries to the terminfo database, but it is a tedious and time-consuming process. Describing how to add entries to the terminfo database is beyond the scope of this book.
Daemons and LP Internal Files
The /usr/lib/lp directory contains daemons and files used by the LP print service, as described in Table 91.
Table 91. Contents of the /usr/lib/lp Directory
Contains files for generating printing alerts, slow filters, and queue management programs.
Contains LP executables for the local system.
Contains locale information.
Manage scheduling of LP print requests.
Contains the standard printer interface program.
Contains all PostScript filter programs provided by the Solaris LP print service. These filters come with descriptor files in the /etc/lp/fd directory that tell the LP print service the characteristics of the filters and where to locate them.
LP Administrative Commands
The commands used to set up and administer the LP print service are in the /usr/sbin directory; they are listed in Table 92.
Table 92. The LP Commands in the /usr/sbin Directory
Accept print requests into the printer's queue or reject print requests.
Define printer names, printer types, file content types, print classes, printer devices, and printer comments; remove printers or print classes; specify fault recovery, interface programs (either custom or standard), printing options, banner/no banner; mount forms; mount print wheels or cartridges; define allow and deny user lists.
Add, change, delete, and list filters.
Add, change, delete, and list forms.
Move queued print requests from one printer to another.
Halt the LP print service (the lpsched command, which starts the LP print service, is in the /usr/lib/lp directory).
Register print servers and print clients with the LP print service.
Set queue priorities for users.
The LP print service maintains two sets of log files: a list of current requests that are in the print queue (/var/spool/lp) and an ongoing history of print requests (/var/lp/logs/requests).
Print Queue Logs
The scheduler for each system keeps a log of print requests in the directories /var/spool/lp/requests/system and /var/spool/lp/tmp/system. Each print request has two files (one in each directory) that contain information about the request. The information in the /var/spool/lp/requests/system directory can be accessed only by root or lp. The information in the /var/spool/lp/tmp/system directory can be accessed only by root, lp, or the user who submitted the request.
The following example shows the contents of the /var/spool/lp/tmp/pine directory. See Table 93 on page 406 for an explanation of the LP requests log codes.
pine% ls /var/spool/lp/tmp/pine
pine% cat 21-0
These files remain in their directories only as long as the print request is in the queue. Once the request is finished, the information in the files is combined and appended to the /var/lp/logs/requests file, which is described in the next section.
Use the information in the /var/spool/lp logs if you need to track the status of a print request that is currently in the queue.
The LP print service records a history of printing services in the lpsched and requests log files. These log files are located in the /var/lp/logs directory. You can use the information in these logs to diagnose and troubleshoot printing problems. The following example shows the contents of the /var/lp/logs directory.
# cd /var/lp/logs
lpsched.1 requests requests.2
lpsched lpsched.2 requests.1
The files with the .1 and .2 suffixes are copies of logs for previous days. Each day, the lp cron job cleans out the lpsched and requests log files; it keeps copies for two days.
The most important log file for troubleshooting is the lpsched log, which contains information about local printing requests.
The requests log contains information about print requests that have completed and are no longer in the print queue. Once a request is finished printing, the information in the /var/spool/lp log files is combined and appended to the /var/lp/logs/requests file.
The requests log has a simple structure, and you can extract data by using common UNIX shell commands. Requests are listed in the order in which they are printed and are separated by lines showing their request IDs. Each line below the separator line is marked with a single letter that identifies the kind of information contained in that line. Each letter is separated from the data by a single space.
The following example shows the contents of a requests log.
# tail requests.2
= slw2-20, uid 200, gid 200, size 5123, Thu Nov 18 01:24:01 EST 2000
Table 93 shows the codes in the LP requests log.
Table 93. Codes in the LP requests Log
The separator line. It contains the following items, separated by commas: the request ID, the user ID and group IDs of the user, the total number of bytes in the original (unfiltered) files, and the time the request was queued. The user ID, group IDs, and file size are preceded by the words uid, gid, and size.
The number of copies printed.
The printer or class destination or the word any.
The name of the file printed. The line is repeated for each file printed; files were printed in the order shown.
The name of the form used.
One of three types of special handling: resume, hold, and immediate. The only useful value found in this line is immediate.
The type of alert used when the print request was successfully completed. The type is the letter M if the user was notified by e-mail or W if the user was notified by a message to the terminal.
The -o options.
The priority of the print request.
The list of pages printed.
This single-letter line is included if the user asks for raw processing of the files (the -r option of the lp command).
The character set or print wheel (or cartridge) used.
The outcome of the request, shown as a combination of individual bits expressed in hexadecimal form. Although several bits are used internally by the print service, the most important bits are listed below.
0x0004 Slow filtering finished successfully.
0x0010 Printing finished successfully.
0x0040 The request was cancelled.
0x0100 The request failed filtering or printing.
The title placed on the banner page.
The type of content found in the file(s).
The name of the user who submitted the print request.
The slow filter used for the print request.
The list of special modes to give to the print filters used to print the request.
The printer used for the request. This printer differs from the destination (the D line) if the request was queued for any printer or a class of printers or if the request was moved to another destination.
Files queued for printing are stored in the /var/spool/lp directory until they are printed. Table 94 shows the contents of the /var/spool/lp directory.
Table 94. Contents of the /var/spool/lp Directory
Lock file for the scheduler. Check for this file if the scheduler dies and won't restart.
Linked to /etc/lp.
Linked to /usr/lib/lp/bin.
Contains pipes that convey networked print requests to and from the inet daemon.
Linked to ../lp/logs where completed print requests are logged.
Linked to /usr/lib/lp/model.
Contains a directory for each configured printer where print requests are logged until printed. Users cannot access this log.
Contains a print status file for the system.
Linked to /var/spool/lp/tmp/printer-name, which contains the spooled requests.
Contains a directory for each configured printer where print requests are logged until printed. Changes to existing print requests are also recorded in this log.