Section 3.23. Printing a File: lplpstatcancel


[Page 64]

3.23. Printing a File: lp/lpstat/cancel

Now that the hard work is done, I want to obtain a printout of my lyrics to sing from. I can use the GNU utility, patterned after the System V UNIX utility, called lp (Figure 3-26).

Figure 3-26. Description of the lp command.

Utility: lp [-d destination] [-n copies] { fileName }*

lp prints the named files to the printer specified by the -d option. If no files are specified, standard input is printed instead. By default, one copy of each file is printed, although this may be overridden using the -n option.


lp causes a numbered print job to be started for the specified files. You may find the status of a particular job and/or printer by using the lpstat utility (Figure 3-27).

Figure 3-27. Description of the lpstat command.

Utility: lpstat [destination]

lpstat displays the status of all print jobs sent to any printer with the lp command. If a printer destination is specified, lpstat reports queue information for that printer only. lpstat displays information about the user, the name and size of the job, and a print request ID.


If for some reason you wish to cancel a print job, you may do so by using the cancel utility (Figure 3-28). You will need the request ID displayed by lpstat.

Figure 3-28. Description of the cancel command.

Utility: cancel { request-ID }+

cancel removes all of the specified jobs from the printer queue. If you're a super-user, then you may cancel any queued job.


You may obtain a list of the printers on your system from your system administrator.

In the following example, I started by ordering a printout of "heart.final" from the "lwcs" printer. I then decided to order two more copies, and obtained a printer status. Finally, I changed my mind and canceled the last print job.


[Page 65]

$ lp -d lwcs heart.final     ...order a printout. request id is lwcs-37 (1 file) $ lpstat lwcs            ...look at the printer status. printer queue for lwcs lwcs-36       ables      priority 0  Mar 18 17:02 on lwcs       inventory.txt                     457 bytes lwcs-37       glass      priority 0  Mar 18 17:04 on lwcs       heart.final                       213 bytes $ lp -n 2 -d lwcs heart.final       ...order two more copies. request id is lwcs-38 (1 file) $ lpstat lwcs      ...look at the printer status again. printer queue for lwcs lwcs-37       glass      priority 0  Mar 18 17:04 on lwcs       heart.final                       213 bytes lwcs-38       glass      priority 0  Mar 18 17:05 on lwcs       heart.final      2 copies         213 bytes $ cancel lwcs-38         ...remove the last job. request "lwcs-38" cancelled $ _ 


In the next example, I used the keyboard to compose a quick message for the printer:

$ lp -d lwcs             ...print from standard input. Hi there, This is a test of the print facility. - Graham ^D      ...end of input. request id is lwcs-42 (standard input) $ _ 





Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net