The LP (for line printer subsystem) print service is the portion of SunOS which provides the tools used for printing. It provides a wide variety of functions, many of which are not within the scope of this manual. This chapter provides only the procedures necessary for you to perform the following basic printing tasks using the LP print service:
Submitting a print request (sending a file to the printer)
Determining a printer's status
Cancelling a print request
See System Administration Guide, Volume II for a complete description of the LP print service.
To print a file from the command prompt, you use the lp command to send a request to the printer to print that file. When a request is made, the LP print service places it in the queue for the printer, displays the request ID number, and then redisplays the shell prompt.
When the LP print service is set up with a default printer, you can submit print requests as follows without typing the name of the printer:
$ lp filename |
where filename is the name of the file you want to print.
The specified file is placed in the print queue of the default printer, and the request id is displayed.
For example, to print the /etc/passwd file, type:
$ lp /etc/passwd request id is pinecone-8 (1 file) $ |
See System Administration Guide, Volume II for information on how to specify a default printer.
Whether or not a default printer has been designated for your system, you can submit print requests to any printer that is configured for your system. To submit a print request to a specific printer, type the following:
$ lp -d printername filename |
where printername is the name of the specific printer and filename is the name of the file you want to print.
The specified file is placed in the print queue of the destination printer, and the request id is displayed.
For example, to print the /etc/passwd file on the printer acorn, type:
$ lp -d acorn /etc/passwd request id is acorn-9 (1 file) $ |
If you submit a request to a printer that is not configured on your system, an information message is displayed, as shown in the following example:
$ lp -d thorn /etc/passwd UX:lp: ERROR: Destination "thorn" is unknown to the LP print service. $ |
See System Administration Guide, Volume II for information on configuring printers. See "8.2 Determining Printer Status", in this chapter, for information about how to find out which printers are available on your system.
When you submit a large file for printing, you may want the LP print service to notify you when printing is complete. You can request that the LP print service notify you in two ways:
Send an email message
Write a message to your console window
To request email notification, use the -m option when you submit the print request:
$ lp -m filename |
To request a message be written to your console window, use the -w option when you submit the print request:
$ lp -w filename |
where filename is the name of the file you're printing.
You can print more than one copy of a file. When you request more than one copy, the file is printed the number of times you specify using the -n option to the lp command. The print request is considered as one print job, and only one header page is printed.
Enter the following to request multiple copies:
$ lp -nnumber filename |
where number is the desired number of copies and filename is the name of the file you are printing.
For example to print four copies of the /etc/passwd file:
$ lp -n4 /etc/passwd request id is pinecone-9 (1 file) $ |
You can customize your print request using options to the -lp command: specifying forms, character sets, filters, titles, banners, and so forth. Table 8-1 summarizes the frequently used options for the lp command. You can use these options individually or combine them in any order on the command line. When you combine options, use a space between each option and repeat the dash (-).
For example, to specify a destination printer, request email notification, and print six copies of a file, you would enter the following:
$ lp -d printername -m -n6 filename |
where printername is the name of the desired printer and filename is the name of the file you are printing.
Table 8-1 Summary of Frequently Used lp Options
Option |
Description |
---|---|
Destination. Specifies a destination printer by name. |
|
Mail. Sends email to the requestor when the file has printed successfully. |
|
Number. Specifies the number of copies to be printed. |
|
Title. Specifies a title (printed only on the banner page) for a print request. |
|
Option. Suppresses printing of the banner page for an individual request. |
|
Header. Puts a header on each page of the print request. |
|
Copy. Copies the file before printing. |
|
Write. Writes a message to your terminal when the file has printed successfully. |
See the lp(1) man page for a complete list of options.
Use the lpstat command to find out about the status of the LP print service. You can check on the status of your own jobs in the print queue, determine which printers are available for you to use, or determine request ids of your jobs if you want to cancel them.
Enter the following to find out the status of your own spooled print requests:
$ lpstat |
A list of the files that you have submitted for printing is displayed.
In the following example, on the system pine, one file is queued for printing to the printer pinecone:
$ lpstat pinecone-10 fred 1261 Mar 12 17:34 on pine $ |
The lpstat command displays one line for each print job, showing the request id, followed by the user who spooled the request, the output size in bytes, and the date and time of the request.
To find out which printers are configured on your system, type the following:
$ lpstat -s |
The status of the scheduler is displayed followed by the default destination and a list of the systems and printers that are available to you.
In the following example, on the system elm, the scheduler is running, the default printer is pinecone, and two network printers, pinecone and acorn, are available:
$ lpstat -s scheduler is running system default destination: pinecone system for pinecone: pine system for acorn: oak $ |
The -t option for lpstat gives you a short listing of the status of the LP print service.
To display a short listing of all status information, type the following:
$ lpstat -t |
All available status information is displayed.
In the following example, there are no jobs in the print queue. When files are spooled for printing, the status of those print requests is also displayed:
You can request printer status information for individual printers using the -p option to lpstat. This option shows whether the printer is active or idle, when it was enabled or disabled, and whether it is available to accept print requests.
To request status for all printers on a system, type the following:
$ lpstat -p |
In the following example, two printers are idle, enabled, and available. If one of those printers had jobs in the print queue, those jobs would also be displayed.
$ lpstat -p printer pinecone is idle. enabled since Wed Jan 2 18:20:22 PST 1991. available. printer acorn is idle. enabled since Mon Mar 4 15:53:44 PST 1991. available. $ |
To request status for an individual printer by name, type the following:
$ lpstat -p printername |
where printername is the name of the specific printer.
If you want to see all of the characteristics for a printer, use the -p option together with the -l (long) option to lpstat. This command can be especially useful for finding the printer type and content type.
To show characteristics for all printers on a system, enter the following:
$ lpstat -p -l |
A table shows all the configuration information that is used by the LP print service for each printer.
In the following example, all of the fields are blank except for the content type and the printer type of the printer pinecone.
You can request different types of printing status information using the lpstat command. Table 8-2summarizes the frequently-used options for the lpstat command. Use these options individually, or combine them in any order on the command line. When you combine options, use a space between each option and repeat the dash (-).
For example, to show a long list of status for an individual printer, you would enter the following:
$ lpstat -p printername -l |
where printername is the name of the printer for which you want to view status.
Table 8-2 Summary of Frequently Used lpstat Options
Option |
Description |
---|---|
Accept. Show whether print destinations are accepting requests. |
|
Class. Show classes and their members. |
|
Destination. Show default destination. |
|
Forms. Show forms. |
|
Output. Show status of output. |
|
Printer/Description/Long list. Show status of printers. |
|
Request. Request scheduler status. |
|
Show position of job in the queue |
|
Status. Show status summary |
|
Sets. Show character sets |
|
User. Show requests by user |
|
Show devices |
See the lpstat(1)man page for a complete list of options.
Use the cancel command to cancel a print request while it is in the queue or while it is printing. To cancel a request, you need to know its request id. The request id always includes the name of the printer, a dash, and the number of the print request. When you submit the print request, the request id is displayed. If you do not remember your request id, type lpstat and press Return. Only the user who submitted the request, or someone logged in as root or lp can cancel a print request.
To cancel a print request, type the following:
$ cancel requestid |
where requestid is the request id number of the desired print request.
A message is displayed telling you that the request is canceled. The next job in the queue begins printing.
In the following example two print requests are canceled:
$ cancel pinecone-3 pinecone4 request "pinecone-3" cancelled request "pinecone-4" cancelled $ |
You can also cancel just the job that is currently printing (if you submitted it) by typing the printer name in place of the request id as follows:
$ cancel printername |
where printername is the name of the printer to which you sent the request.
A message is displayed telling you that the request is canceled. The next job in the queue begins printing
In the following example the currently printing request has been canceled:
$ cancel pinecone request "pinecone-3" cancelled $ |
Your system administrator can log in as root or lp and cancel the currently printing request using the printer name as the argument for the cancel command.