Next | Prev | Up | Top | Contents | Index

Command Interface to lp

The command interface to lp consists of a set of commands for users sending their jobs to the printer and a set of administrator commands for managing printer resources.

The lp spooling utility allows

User Command Summary

The commands described in this section allow users on workstations and across the network to access the printing facilities. Users should use the lp and cancel commands most frequently, the lpstat command occasionally, and the enable and disable commands infrequently, if ever. No special privileges are necessary to use these commands.

This section describes the five basic lp commands.

lp

Routes jobs to a destination and places them in a queue. The destination may be either a single printer or a class of printers.

cancel

Cancels spooled print requests.

lpstat

Reports the status of the lp spooling system.

lp: Send a Print Job to a Printer

The lp command routes a print job request to a destination where it is placed in a queue to await printing. The destination may be a single printer or a class of printers. If you do not specify a destination, the request is routed to the default destination. For information on how to set the default printer destination, see "Changing the Default Printer Destination".

The form of the lp command is

lp [options] filename...

Every time an lp request is made, a request ID is assigned to the job and a record of the request is sent to you. The request ID has this form:

destination-seqnum

destination is the printer or class of printers to which the job has been routed. seqnum is an arbitrary sequence number assigned to the job by the lp system.

lp has three options that are particularly useful: -n, -d, and -c.

You can combine these command options in any order. For a complete list of lp options, see the lp(1) reference page. Example 2-1 and Example 2-2 show some uses of the lp command.

Example 2-1 : Simple lp Print Requests

lp myfile

lp < myfile

cat myfile | lp

To request a printout, you can use the lp command several different ways. The entries in Example 2-1 perform identical functions, sending a simple print request to the default printer.

Example 2-2 : Complex lp Print Request

lp -n3 -dfoo -c myfile

The entry in Example 2-2 prints three copies on printer foo and creates a copy of the file for the printer to process, ensuring that if changes are made to the file after the print request, the original file is printed.

cancel: Remove a Print Request

The cancel command removes a job from the queue. You can cancel a job either before or after it starts printing.

Any user can cancel any other user's job. If you cancel another user's print request, mail is sent to that user. Once you cancel a job, you can request that it be printed again only with the lp command:

cancel printer-name

cancel request-ID ...

Using the printer-name cancels the job currently being printed. Using the request-ID cancels the specified job(s) whether or not it is currently being printed, as shown in Example 2-3.

Example 2-3 : Using the cancel Command

cancel myprinter request "myprinter-16" cancelled

cancel myprinter-17 request "myprinter-17" cancelled

Issuing a cancel command does not work when the job is being printed on a remote printer. To cancel a print job on a remote printer, log in to the remote system and issue the cancel command.

lpstat: Report lp Status

The lpstat command reports the status of various aspects of the lp system. To check lp status, type

lpstat [options]

Use the -t option to display a complete report on the status of the lp system.

For a complete list of options, see the lpstat(1) reference page.

Example 2-4 shows a sample lpstat -t command and its result:

Example 2-4 : Using the lpstat Command

lpstat -t scheduler is running system default destination: myprinter members of class foo: myprinter device for myprinter: /dev/plp myprinter accepting requests since Jul 31 21:40 foo accepting requests since Jul 30 12:23 printer myprinter now printing foo-18 enabled since Aug 5 15:34 foo-18 mylogin 3156 Aug 7 17:11 on myprinter

Administrator Command Summary

This section summarizes the administrative commands that control the lp system. To execute administrative commands, you must be logged in as either root (that is, the superuser) or lp. Inexperienced users should not use the lp administrative commands.

lpsched

Starts the lp scheduler

lpshut

Stops the lp scheduler

disable

Prevents a printer from printing jobs that are in the queue

enable

Allows a printer to print jobs in the queue

reject

Prevents jobs from queueing at a particular destination

accept

Permits job requests to queue at a particular destination

lpmove

Moves job requests from one destination to another

lpadmin

Configures the lp system

lpsched: Start the lp Scheduler

The lpsched command starts the lp scheduler, the background daemon responsible for scheduling lp requests. lp prints jobs only when the scheduler is running on that system. lpsched is executed automatically each time the computer is booted.

Every time lpsched is executed, it creates a file called SCHEDLOCK in /var/spool/lp. When the scheduler is stopped under normal conditions, SCHEDLOCK is automatically removed. As long as this file exists, the system does not allow another lp scheduler process to run. If the scheduler stops abnormally (for example, if the system shuts down abnormally), you must remove SCHEDLOCK before you use the lpsched command.

To start the lp scheduler, type

/usr/lib/lpsched

There is no response from the system to acknowledge the lpsched command; to verify that the scheduler is running, use lpstat.

You can disable lpsched from starting at boot time using chkconfig(1M). The command

chkconfig lp off

prevents lpsched from running at system startup. To enable lpsched at system startup, enter

chkconfig lp on

lpshut: Stop the lp Scheduler

The lpshut command stops the lp scheduler and ends all printing activity. All requests that are being printed when you issue the lpshut command are reprinted in their entirety when the scheduler is restarted.

To stop the lp scheduler, type

/usr/lib/lpshut

disable: Stop Printer From Processing Requests

The disable command prevents the printer from printing jobs in the queue. Possible reasons for disabling the printer include malfunctioning hardware, paper jams, running out of paper, or end-of-day shutdowns. If a printer is busy at the time it is disabled, the request it was printing is reprinted in its entirety when you reenable the printer.

You can send job requests to a printer that has been disabled. The jobs are put in the queue but are not printed until the printer is enabled.

To disable a printer, type

disable [-c] [-r"reason"] printer(s)

enable: Allow Printer to Process Requests

The enable command permits a printer that has been disabled to begin printing jobs from the queue. Example 2-5 shows how to use the enable command. To enable a printer, type

enable printer...

Example 2-5 : Using the enable Command

disable -r"paper jam" myprinter printer "myprinter" now disabled

enable myprinter printer "myprinter" now enabled

reject: Prevent Print Requests

The reject command stops lp from routing requests to a destination queue. For example, if a printer has been removed for repairs, or has received too many requests, you may wish to prevent new jobs from being queued at that destination.

If the printer is enabled, all requests that are in the queue when you issue the reject command are printed.

The reject command takes the form

/usr/lib/reject [-r"reason"] destination

Use the -r option to tell other users why print requests are being rejected. reason is a character string and is enclosed in double quotation marks (" "). This string is reported to anyone trying to use lp to send requests to the specified destination.

accept: Allow Print Requests

The accept command allows job requests to be placed in a queue at the named printer(s) or class(es) of printer(s). As shown in Example 2-6, accept allows a printer to receive job requests and reject disables printing:

Example 2-6 : Using the accept and reject Commands

/usr/lib/accept myprinter destination "myprinter" now accepting requests

/usr/lib/reject -r"printer broken" myprinter destination "myprinter" is no longer accepting requests

lpmove: Move a Request to Another Printer

The lpmove command moves print requests from one destination to another. For example, if you have a printer removed for repairs, you may want to move all jobs pending on the queue to a destination with a working printer. You may also use lpmove to move specific requests from one destination to another but only after you have halted the scheduler with the lpshut command. lpmove automatically rejects job requests rerouted to a destination without a printer. The lpmove command takes two forms:

/usr/lib/lpmove dest1 dest2

/usr/lib/lpmove request(s) destination

dest1, dest2, and destination are printers or classes of printers. request is a specific request ID.

In the first form of the command, all requests are moved from dest1 to dest2. After the move, the printer or printers at dest1 does not accept requests until you issue an accept command. All rerouted requests are renamed dest2-nnn, where nnn is a new sequence number in the queue for destination dest2. In the second form, which you can issue only after you stop the scheduler, the rerouted requests are renamed destination-nnn. When you restart the scheduler, the original destinations still accept new requests. Example 2-7 demonstrates the use of the lpmove and lpshut commands.

Example 2-7 : Using the lpmove and lpshut Commands

/usr/lib/lpmove myprinter yourprinter

lpshut

/usr/lib/lpmove foo-19 foo-20 yourprinter total of 2 requests moved to yourprinter

lpadmin: Configure Printers

The lpadmin command has two primary uses:

Unlike most IRIX commands, lpadmin requires an option. The lpadmin command takes three forms:

lpadmin -ddestination

lpadmin -xdestination

lpadmin -pprinter [options]

In Example 2-8, the first entry shuts down the lp scheduler. The second entry removes the printer myprinter from the lp spooling system. The printer myprinter is then removed from the foo class and assigned to the boo class with the third entry.

Example 2-8 : Using the lpadmin Command

/usr/lib/lpshut

/usr/lib/lpadmin -xmyprinter

/usr/lib/lpadmin -pmyprinter -rfoo -cboo

For a complete list of options, see the lpadmin(1M) reference page.


User Command Summary
lp: Send a Print Job to a Printer
cancel: Remove a Print Request
lpstat: Report lp Status
Administrator Command Summary
lpsched: Start the lp Scheduler
lpshut: Stop the lp Scheduler
disable: Stop Printer From Processing Requests
enable: Allow Printer to Process Requests
reject: Prevent Print Requests
accept: Allow Print Requests
lpmove: Move a Request to Another Printer
lpadmin: Configure Printers

Next | Prev | Up | Top | Contents | Index