< Day Day Up > |
UNIX and UNIX-like systems run a variety of programs related to printing called lp (for line printing). These programs work together to support printing of text files, formatted documents, graphics files, and so on. This section covers the basics of printing, including some of the basics of printer administration. To simply print a file called mbox, you would use the lp (short for line printer) command, as shown in the following example: martyp $ lp mbox Job number is: 1 martyp $ In this example, you requested that the file mbox be printed. You receive a return message from lp, indicating the request identification number. You can print multiple files with one lp request, as shown in the following example: martyp $ ls -l total 80 -rw------- 1 martyp usr 350 Sep 27 07:22 dead.letter -rw-rw-r-- 1 martyp usr 24576 Sep 6 07:07 inst.out -rw-rw-r-- 1 martyp usr 0 Aug 21 06:45 lanadmin.list -rw------- 1 martyp usr 1485 Sep 27 08:20 mbox -rw-rw-r-- 1 martyp usr 353 Sep 29 04:57 trip -rw-rw-r-- 1 martyp perf 635 Mar 21 1999 typescript martyp $ lp t* Job number is: 2 martyp $ In this example, both files beginning with "t" were printed, and one job number is associated with the printing of both files. Many UNIX systems have multiple printers connected. You can specify the printer you want to send the file(s) to with the -d option followed by the printer name. In the previous examples, the default system printer was used. You can specify the printer device to which our earlier print of mbox will go with the -d option, as shown in the following example: martyp $ lp -d ros2228 mbox Job number is: 3 martyp $ This output sends the file mbox to the printer we have specified, and again the job number is specified. You can specify a default printer by setting the LPDEST environment variable. If set, this variable will be used when you do not specify a printer name, as shown in the following example: martyp $ LPDEST=ros2228 martyp $ export LPDEST martyp $ lp mbox Job number is: 4 martyp $ The LPDEST environment variable is normally associated with a user's default printer. You can also specify the default printer in your startup file. Print jobs are spooled to a printer so that you can proceed with other work. You don't have to wait until a print job completes without a problem before you move on. You can receive an electronic mail message if there was any problem with your print job using the -m option, as shown in the following example: martyp $ lp -m t* Job number is: 5 martyp $ In this case, we have again sent the two files beginning with "t" to the default printer we earlier set up. You can assume this print job will complete without any problem unless you receive an electronic mail message informing you otherwise. Sometimes, you may want to see the status of printers on or attached to your system or network. The spooling functionality means that several files can be spooled to the printer, which means that you may have to wait for your file to print. There may only be one file ahead of yours in the print queue; however, it may be a very large file, such as a report from an ERP system. To obtain the status of printers, use the lpstat command. I normally issue this with the -t option to obtain a long status listing, as shown in the following example: martyp $ lpstat -t Queue Dev Status Job Name From To Submitted Rnk Pri Blks Cp PP % ------- ----- --------- --------- --- --- ----- --- ---- -- a464 a464d READY a464: no entries a438 a438d READY a438: no entries a570 a570d READY a570: no entries a654 a654d READY a654: no entries a662 a662d READY a662: a662: a662: a662: a662: a946 a946d READY a946: no entries a956 a956d READY a956: no entries a732 a732d READY a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down a732: rosps4: Warning: a732 is down ros2227 ros22 READY ros2227: no entries ros2228 ros22 READY ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: martyp $ The output shows the status of all printers available to your system. You can see in this example that there are many printers connected to this system. I removed several printers from this output, because it was too long to include in this book. Several of the printers report warning messages indicating that they are "down," which of course, means that they are unable to print. We won't get into the troubleshooting of such problems here, because this is almost exclusively a problem that would be handled by the system administrator. If you want to obtain the status of the default printer, which was just set up, you can do so with the -d option, as shown in the following example: martyp $ lpstat -d Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --- --- ros2228 ros22 READY ros2228: ros2228: ros2228: ros2228: ros2228: ros2228: martyp $ I often pull the trigger too quickly on a print job and need to cancel it. After a job is submitted, you can remove it with the cancel command, along with the job id. You can use the job number shown in earlier examples, along with the cancel command or use the printer name along with cancel. Small print jobs will normally be processed and printed too quickly to cancel. Large print jobs, however, may be canceled before they are complete. You can use the lpstat command to obtain the job number, in the event that you did not write it down when you submitted the job. Table 10-3 lists some of the most commonly used lprelated commands. Keep in mind that some of these are associated with system administration work, such as configuring printers and are not normally used by users.
|
< Day Day Up > |