Objectives| Introduction| Hardware| Software| The SysV Print Software| The BSD Print Software| /etc/printcap| The BSD Print Commands| Conclusions| Review Questions
UNIX print software performs a number of tasks including
Figure 11.1. Possible Hardware Problems with Printer Connections.
All UNIX print software has at least the following two components
Both SysV and BSD print services also support the concept of an interface program. This program acts as a filter through which all output sent to the printer is passed through. Example uses of an interface program include
Term Definition device the actual physical printer printer the interface program/connection to the device class a group of similar printers known by one name Table 11.1. System V Printer Definitions.The entire spooling system is a complex system. The following diagram provides a simplification of the systems operation.
Diagram 11.1. System V Print Spooling System.
lpsched is the name of the daemon that is continually running and provides the "power" for the print service. Only one copy of lpsched should be running at any one time. There should be a file SCHEDLOCK in /usr/spool which is responsible for ensuring only one copy runs.
lpshut turns off the print service by killing the lpsched daemon. Print jobs can still be spooled while lpsched is not running but they won't be printed. You should always run lpshut before using lpadmin.
Command Purpose accept/reject allows/disallows any further requests for a printer or class entering the spooling area cancel allows user to stop the printing of information enable/disable allow/disallow any more output from the spooler to the printer lpmove move print requests between destinations lp THE USER'S PRINT COMMAND, places information to be printed into the spooler lpadmin allows the configuration of the print service lpsched start the print service lpshut stop the print service lpstat display status of the print service Table 11.2. System V Print Service Commands.
lpshut lpadmin -pprinter -vdevice -mmodel lpsched accept printer enable printer
Component Purpose lpc make administrative changes to the print service lpd the daemon, a copy is spawned for each queue, transfers information from spooling area to physical device lpq view the contents of a print queue lpr the user print command, spools information to be printed /etc/printcap system's printer information database lprm removes print jobs from queues Table 11.3. BSD Print Service Components.
Diagram 11.2. BSD Print Service.
Each printer connected to a BSD system must have its own spooling directory that is serviced by one lpd daemon. Each printer has its own lpd daemon.
lpd accesses the file /etc/printcap for any information it requires concerning the printer. /etc/printcap is the system's printer database file and stores all the necessary information about ALL printers connected to the system. To use a printer, that printer must have an entry in /etc/printcap.
lpr is BSD's equivalent to lp under System V. If a user wishes to print something they use lpr. lpr sends this information to a specified spooling directory.
The process for adding a printer to a BSD system is somewhat similar to that for SysV.
lpc enable printer_name start printer_name quit
The configuration settings can take one of three possible formats
For example:
Specify the location of the spool directory for a printer sd=/usr/spool/lp/scribe Force a form feed when the device is first opened fo Specify the maximum size (in blocks) of files that can be printed mx#3 Setting Purpose sd=directory specify spool directory lf=file specify error log file lp=file specify device file af=file specify accounting file rw specify that printer can both read and write infomation (can send status info back to computer) br#number specify baud rate fc#number * specify flag bits to turn off fs#number * specify flag bits to turn on xc#number * specify local mode bits to turn off xs#number * specify local mode bits to turn on pl#number specify page length in lines pw#number specify page width in characters py#number specify page height in pixels px#number specify page width in pixels ff=string specify string that causes printer to form feed fo output form feed when device is opened mc#number specify maximum number of copies of a job allowed mx#number specify maximum file size in blocks allowed sc specify that multiple copies should be prevented sf specify that form feeds should be prevented sh suppress the printing of headers * see explanation below Table 11.4. Configuration Settings for /etc/printcap.
The values for these fs and fc are obtained by adding the octal values from Table 11.5 together.
For example:
Clear all delay bits and echo/full duplex 0040000 + 0010000 + 0020000 + 0002000 + 0000400 + 0001000 + 0000010 = 0073410 printtab entry = fc#0073410 Set even and odd parity, enable automatic flow control. 0100 + 0200 + 0001 = 0301 printtab entry = fs#0301Remember these numbers are in octal (base 8). If you don't know how to do addition in base 8 obtain a calculator which supports octal. Most good scientific calculators should.
Octal Value Description 0040000 form feed delay, 2 seconds 0010000 carriage return delay, 0.08 second 0020000 carriage return delay, 0.16 second 0002000 tab delay 0000400 newline delay 0001000 newline delay, 0.1 second 0000200 even parity 0000100 odd parity 0000040 pass all characters from filter to printer immediately 0000020 translate linefeed into carriage return&linefeed 0000010 echo, full duplex 0000002 pass characters from printer to filter immediately 0000001 automatic flow control Table 11.5. Flag Bits for a Serial Printer.
Octal Value Description 000040 prevent serial driver from playing with codes destined for printer 040000 minimize flow control interference from line noise 000001 tell the printer to backspace when it receives an erase character Table 11.6. Local Mode Bits for a Serial Printer.
lpq [-Pprinter][-l][+[interval]][job#...][username]With no parameters lpq will display a list of all print jobs on the default printer.
Options Purpose -P printer display the queue of the specified printer -l display using long format +[interval] display the queue periodically until it empties, interval specifies how many seconds it should sleep job# display only those jobs with matching job numbers username display only jobs belonging to the specified user Table 11.7. lpq Command Options.
lpr [-Pprinter][-#copies] filenames Options Purpose -Pprinter specify printer to send information to, by default this is lp -#copies produce the number of copies indicated Table 11.8. lpr Command Options.
lprm [-Pprinter][-][ job#...][username...]lprm is used to remove jobs from the printer queue. It removes jobs matching printer, job# and username. The printer name defaults to lp and the job number defaults to the current job. Username defaults to the user invoking it.
Only the root user can remove someone else's print job.
lpc [ command [ parameter.. ]]If no commands are given lpc will enter interactive mode and present the lpc> prompt at which commands can be given.
Table 11.9 lists some of the commands that can be given to lpc. There are a number of other commands, refer to your manual page. These commands can be given at both the command line and from the lpc> prompt.
Command Purpose ? [command] help [command] provide short description of command abort [all | printer ] terminate the daemon and then disable printing for the specified printers. enable [all | printer ] start spooling for the specified printers start [all | printer ] start printing for the listed printers stop [all | printer ] stop a spooling daemon and disable printing Table 11.9. lpc Command Options.Exercise 11.2. Complete the software process for connecting your printer to your UNIX box.
The UNIX print software is much more complex than that of a single-user operating system and is based on the concept of print spooling. The print services of BSD and SysV are completely different.
11.2. What is the purpose and relationship between the lp and lpr commands?
11.3. What is the purpose and relationship between lpd and lpsched?
11.4. What is the purpose of the /etc/printcap file?
David Jones (author)