BSD Printing Subsystem UNIX Printing Subsystem

Figure 10.1: Functional diagram of a printing subsystem. Once a user or a users process, invokes a printing, the print command performs the following: It looks in the printer database for necessary printing−related data such as the spooling directory and other printing arguments. • It creates a print job a print request for System V printing subsystem and puts a corresponding control and data file cf and df in a printing queue in the corresponding spooling directory, and if it is a BSD printing subsystem, copies the file to be printed into the spooling directory. • It notifies the print daemon about the started printing procedure. • The print daemon provides the actual printing: It looks in the printer database for necessary printer−related data for the started print jobrequest. • It checks the status of the corresponding printer. • It completes the printing procedure by sending the file to the printer for printing. • The start of printing and the actual printing do not necessarily coincide; a delay between the two actions is quite possible, and such delays can vary significantly, depending on the actual printer status, the volume of required printing, the queue length, and other factors. Generally, the physical printing is performed slowly, and sometimes the delays can be quite annoying.

10.1.1 BSD Printing Subsystem

The BSD UNIX system maintains multiple printers on local andor remote sites, and multiple print queues. It can be adopted to support different types of printers. It began as a standard line−printer spooling subsystem, but very soon it added laser printers, raster−printers, and other printing devices. Today the BSD printing subsystem represents a collection of five programs and several files: lpr Adds a print job to a print queue by copying the file into its spooling directory. A print job is assigned a job ID number when it is submitted, and this number is used to refer to the print job in subsequent commands. The name of the command originates from line−printer, the most advanced printer in the early days of UNIX. lpq Lists jobs that are currently in the print queues. lprm Removes jobs from the print queues. Users may remove only their own jobs, but the superuser may remove any print job. lpd The printer daemon, responsible for sending data from the spooling directory to a printer i.e., printing device. 219 etcprintcap The printer configuration file, which contains entries describing each printer on the system. The standard template version includes a number of the most common printers, which an administrator can then customize for a specific system. Usually, entries are commented−out, so the administrator should activate remove the comment markers from all needed entries in the file. Sometimes minor adjustments are required. 10.1.1.1 The lpr, lpq, and lprm Commands The lpr command is available to activate the printing of a printable file: lpr −P printer printfile where −P Option to select a printer for this printing printer The name of the selected printer printfile The name of the file to be printed Please note that there is no space between the −P option and the printer name some UNIX platforms allow this. If the −P option is missing, the default printer is selected. The default printer is defined in the printer configuration file etcprintcap, as are all other printers. The lpq command is available to check the current status of a print queue, i.e. to list the contents of the queue: lpq −P printer where −P Option to select a printer printer The name of the selected printer the queue belongs to If the −P option is missing, the default printer is selected. A few examples: lpq –Ppp no entries post−script printer pp or lpq no entries default local printer The lprm command is available to remove individual print jobs: lprm −P printer jobs−to−remove where −P Option to select a printer 220 jobs−to−remove A list of job IDs A list of usernames for whom to remove all jobs A single hyphen to remove all jobs only if superuser The lprm command identifies print jobs by their IDs obtained with the lpq command; obviously, the lpq command should be issued before the lprm command is used. 10.1.1.2 The lpd Daemon lpd is the BSD printer spooling daemon; it sends data stored in the spooling directory to a printer to be printed. The lpd daemon is started by the corresponding rc start script during system startup. Please note that some UNIX platforms might have a commented rc startup sequence for the printer spooling daemon; the comment markers must be removed from the corresponding lines when the first printer is attached to the system. If they are not removed, the lpd daemon will not be invoked with each subsequent system booting. The lpd daemon works in the logical space between users and printers; this complex task often involves unpredictable conditions that must be handled accordingly. Occasionally, the lpd daemon gets hung. The main symptom of this hung state is a queue filled with jobs but not printing any of them. In this case, the old daemon should be killed and a new one started. The command sequence is shown in the following example: ps −aux | grep lpd | grep −v grep root 208 0.0 0.2 1536 32 ? I 0:00 usrliblpd kill −9 208 usrliblpd 10.1.1.3 Managing the BSD Printing Subsystem The line−printer control utility, lpc is available to perform most administrative tasks connected with the BSD spooling subsystem. The lpc utility includes a number of internal commands subcommands required to handle such printer−related tasks as: shutting a printer down for maintenance, displaying a printers status, and manipulating jobs in print queues. To invoke the lpc utility, simply type: lpc lpc lpc is now running and issues its own prompt. The available internal lpc commands are: status printer Displays the status of the line printer daemon and queue for the specified printer. abort printer Immediately terminates any printing in progress and disables all printing on the specified printer. The job stays in the queue and its printing will continue as soon as the printer is restarted with the start command. stop printer Stops all printing on the specified printer after the current job has finished. New jobs can be added to the queue with the lpr command, but they will not be printed until the printer is started again. This command is very useful when the time comes to add or replace the printers supplies paper, ribbon, etc.. Restarts printing on the specified printer after an abort or stop command. 221 Prevents users except the superuser from putting new jobs into a specified printers queue. Existing jobs continue to print, so this command is useful when a printer needs to be turned off. enable printer Allows users to spool jobs to the queue again, restoring normal operation after the disable command is issued. down printer Stops printing and disables the queue for a specified printer its action is equal to disable plus stop. up printer Enables the queue and starts printing on the specified printer its action is equal to enable plus start. If the specified printer is all, the command itself is forwarded to every printer on the system.

10.1.2 System V Printing Subsystem