Previous Table of Contents Next


Arguments

The following list describes the arguments that may be passed to the lp command.
file_list One or more files to be printed. All files on the command line are printed as one long request. It may be desirable to use the pr command to generate numbered pages with the filename at the top to help distinguish one file from the next.
If no files are specified, the standard input is read and saved in a temporary file for later printing.

FURTHER DISCUSSION

The lp command is the primary user command of an entire UNIX subsystem, called the line printer (lp) subsystem. The user commands of this subsystem are lp, cancel, and lpstat. Each time you send output to the printer lp creates a unique request. The enable and disable commands are sometimes used by the users for printer control. But they are more administrative oriented, and it depends on your system administrator whether or not you have access to them.

Your print jobs are placed in a print queue as printer requests. The request IDs consist of the destination printer name and a sequence number. For example, if you send your files to the "hplj" printer for printing and the last request was number 1287, then your request ID would be hplj-1288.

The requests are processed by lpsched, a background process started when the system is booted. These background processes are referred to as daemons.

The lpsched daemon checks the queue for each printer and if the printer is not busy (in use or jammed), it processes the next request on the printer queue. The file is sent to the printer and lpsched updates the request queue to reflect the change. When the file finishes printing, the request is removed from the queue.

Canceling Request

You can cancel a print request by using the cancel command described in Module 12.

Printer Status

You can check on status of the request queue, the status of the scheduler, and the status of each printer using the lpstat command described in Module 83.

RELATED COMMANDS

Refer to the cancel and lpstat commands described in modules 12 and 83.

RELATED FILES

The standard input is read if no files are given as arguments. Requests generated by lp are printed by lpsched.

/var/spool/lp/* Main directory for spooler related files and queues.

APPLICATIONS

The lp command is used to print files to the system default printer. You can change the destination printer from the default to any that may exist. Because requests are built and queued by lp and the printing is handled by lpsched you do not have to wait for your files (output) to be printed. You can continue working while the system prints your job whenever the printer is available.

TYPICAL OPERATION

In this activity you use the lp command to print a file on your default printer. Begin at the shell prompt.

1.  Type lp file1 and press Return. You see a response from lp resembling the following:
     cj> lp file1
     request id is hplj-1703 (1 file)

The name of the default printer in this case is hplj.
2.  Print a listing of your HOME directory by typing ls | lp -w. Notice a request message is returned to your screen. After your request has completed printing you receive a message on your terminal screen informing you of the completion.
3.  Format the /etc/passwd and /etc/group file using the pr command before spooling them to the default printer. Type pr /etc/passwd /etc/group | lp. The two files are formatted into 66-line pages by pr and sent to lp. You will learn more about pr in a later module.
Find the physical location of the default printer for your system and pick up your printouts.
4.  Turn to Module 12 to continue the learning sequence.


Previous Table of Contents Next