UNIXPrinting

From UMIACS
Revision as of 16:53, 3 December 2008 by Pjk (talk | contribs)
Jump to navigation Jump to search

Introduction

UMIACS uses the LPRng spooling system to provide both a Berkeley UNIX interface to our network printing system.

The commands are located in /usr/local/bin. They include the programs 'lpr', 'lprm', 'lpq', and 'lpstat'.

All of the UNIX queues are configured to handle postscript. See the examples section for more information on how to print different file types. Basic Commands

lpr

Use `lpr -Pprintername filename.ps` to submit the postscript file named filename.ps to the printer queue named printername. If no filename is specified, lpr reads from standard input. If no printer name is specified, then the job is discarded by the print server.

Additional options to specify media handling, page orientation, and double sided printing can be passed to the print spooler using one or more -Z options. Double sided printing is specified with -Zduplex. Page orientation is controlled with -Zportrait, -Zlandscape. Manual feed media (eg. transparencies) is specified with -Zmanual. Please note that not all printers support all -Z options.

nscript

Use `nscript -Pprintername filename.txt` to send the text file named filename.txt to the printer named printername. If no filename is specified, then nscript reads from standard input.

Nscript is a weak attempt to simulate Adobe Systems Incorporated nscript programs. It supports a handful of interesting arguments. With the '-G' argument, nscript generates gaudy output that includes header information on each page. The '-2' argument generates two column output and '-r' rotates the job's orientation to landscape mode.

lprm

Use 'lprm -Pprintername' to remove jobs from the queue named printername. With no further arguments, it removes the first removable job in the queue. Given a job's id as an argument, it will remove the specified job from the queue and you can remove all removable jobs from a queue with the argument "all".

You are able to remove items from the queue that you have submitted from anywhere, not just the computer from which the job was submitted.

lpq

Use 'lpq -Pprintername' to get the status of the queue named printername. With no further arguments, it will print the printer queue, the host queried, and the number of jobs in the queue. With the -l argument, it will specify the id, queue rank, the total size of the job in bytes, and any errors encountered in processing the job.

Generate Postscript

Postscript is a Page Description Language that is understood by high quality printers and typically generated by applications. There is a lot of documentation about using and programming in postscript, but for our purposes you'll just need to generate postscript from an existing text file.

You can generate postscript from an existing text file with textps. For example, to convert the Message of the Day file to a postscript file try `textps ... > file.ps`.

Preview your job

It's helpful to preview your postscript files before printing by calling Ghostview with `ghostview file.ps`.

Higher quality previewing is available using Ghostview's derivativegv. You can call it as `gv file.ps`.

Both commands should open a window that displays the contents of your postscript file.

Choose a print queue

All supported printers are listed at https://printers.umiacs.umd.edu/printers.

You can check list all the print queues with `lpq -a` and you can list just a single queue `lpq -Pprintername` -- eg. ps2109 with `lpq -Pps2109`.

Send a print job

After you choose a suitable printer (eg. ps2109), you can send your postscript file to the printer with `lpr -Pps2109 file.ps`.

Monitor a print job

You can monitor the job you sent to the printer (eg. ps2109) with `lpq -Pps2109`.

Lpq will return the following output:

[herzog 33] lpq -Pps2109
Printer: ps2109@lpr1 (dest raw@ps2109.umiacs.umd.edu) 'HP 8550 in AVW 2109'
Queue: 2 printable jobs
Server: pid 11833 active
Unspooler: pid 11837 active
Status: waiting for subserver to exit at 14:50:45.141
Rank   Owner/ID                  Class Job Files                 Size Time
active fmccall@herzog+198           A   198 file.ps               4309 14:50:44
2      bargle@prime+199             A   199 hpss.ps               4309 14:50:45
Active connection from  128.8.120.247
Waiting connection from 128.8.120.247

Remove a Print Job

If you would like to remove your job from the queue, you should get the job's id from the output of `lpq`. You can remove it with `lprm -Pps2109 198`

From the output of lpq, I can see that the job id is 198 and I can remove it with lprm as follows:

[herzog 35] lprm -Pps2109 198
Printer ps2109@durer:
checking perms 'fmccall@herzog+198'
dequeued 'fmccall@herzog+198'

Often the last job listed in the printer queue has already spooled to the printer, and lprm will be unable to delete the job. In this case, the only way to cancel the job will be to press the 'cancel' button on the printer.