Automating CUPS with shell commands

Status Information

The lpstat command outputs status information about printers, print jobs, and CUPS services (Figure 3). For example, lpstat -r finds out whether the daemon is running. The switch -d identifies the default printer. For a summary of the default printer, the device URI, and its status, use lpstat -t. You can find all the commands available from the man page (man lpstat).

Figure 3: The lpstat command communicates with a printer and outputs its relevant device settings. Here, I'm asking for a long listing (-l) of the Kyocera FS-2000 printer (-p fs2000) settings.

The lpc command provides limited control over printer queues; lpc status lists all available printers. Entering

lpc status | grep : | tr -d \:

reduces the output to just the printer name. To limit the output to a single device, type lpc status <printer>. If lpc is called without any parameters, you land in a command interpreter, which unlike the original from the BSD world, does not offer much functionality.

Administering CUPS

Two command-line tools, cupsdisable and cupsenable, let you control the print queue. Table 4 lists essential commands for cupsenable and cupsdisable (Figure 4).

Table 4

Controlling the Queue

Command

Result

cupsenable <printer>

Start print queue

cupsdisable <printer>

Stop print queue

cupsdisable -r "<reason>" <Printer> or cupsreject -r "<reason>" <Printer>

Stop print queue with message <reason>

cupsaccept <printer>

Accept print jobs

cupsreject <printer>

Reject print jobs

Figure 4: Managing a CUPS queue at the command line.

Using cupsdisable, you can stop a print queue and deactivate the device (e.g., when the device location is changed or repairs are needed). However, you should always inform users about the stoppage. All print jobs are saved when the queue is deactivated, and they can then be resumed with cupsenable. If, instead, you decide to interrupt all print jobs, the print queue should be stopped with cupsdisable -c.

To prevent unnecessary costs associated with the use of specialty printers, such as imagesetters, label printers, and color laser printers, you can refuse to accept (cupsreject) or temporarily permit (cupsaccept) print jobs (Figure 4). CUPS outputs accepted print jobs completely, even if you reject new jobs while the current job is being processed; however, this is not the case when you use cupsenable and cupsdisable to start and stop print queues.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content