Printing Files



next up previous contents index
Next: Editing with vi Up: ViewingEditing, and Previous: More and View

Printing Files

Although we sometimes say a command ``prints'' out a message, most likely the output is appearing on a terminal screen and not on a piece of paper (where respectable printing belongs). There is still power and value in the printed word, and for this purpose a line or page printer is usually attached directly or through a network to your system. 


BSD PRINT
lpr -Pprinter file(s)
Place file(s) in line printer queue.
lpq -Pprinter
List files in line printer queue.
lprm -Pprinter job #
CANCEL a printing job (get # from lpq).
lpc
Line printer control to enable printer.

SYSTEM V PRINT
lpstat
List printers, devices, files in queues.
lp -dprinter filename(s)
Place file(s) in line printer queue.
cancel job #
CANCEL a printing job (get # from lpstat).
enable
ENABLE a printer (may have to be superuser).


BSD uses a system program lpd, a line printer daemon, to control printing to both local and remote printers. This makes the BSD printer commands superior at controlling print jobs on printers connected to remote machines. The -Pprinter option allows the user to send, check status of, or remove a print job from any printer on the network. (Permission to use a printer is given by adding the user's machine name in the file /etc/host.lad on the remote machine which has the printer attached.) If the -P option is omitted, the job is sent to the printer defined in the environment variable PRINTER or, if PRINTER is not defined, to the default printer lp.        

When you give the print command lpr, your print job is placed in the printer queue. If the printer is set and working properly, it will print out your job in turn. To check the status of your print job and to determine its print job number, use the lpq command. To stop a job from printing (say because you submitted the Encyclopedia Britannica by mistake, or because the printer is chewing up your output), try the command lprm or cancel, followed by your job number. Stopping a print job by turning off the power to the printer will certainly stop the printing, but it may disable the printer from further use by the system or confuse a (not so) smart printer or printer spool, or both. The printer can be enabled with the lpc or enable command, but it may take some system work to get the print spooler program working again.   

As an example, here we see bohr finally getting his name in print:

% cd class Change to directory class.
% ls
prog.f One lonely Fortran program.
% lpr prog.f Print prog.f on line printer.
% lpq Tell me files being printed.
lp is ready and printing
Rank Owner Job Files Total Size
active fink 93 guide 367229 bytes
first bohr 94 prog.f 429 bytes
% lprm 94 Stop printing prog.f.
The printer is busy so try elsewhere.
% lpq -Pmath Check the math dept.'s printer.
no entries OK, it's idle.
% lpr -Pmath prog.f Send the file to be printed.
math is ready and printing
Rank Owner Job Files Total Size
active bohr 86 prog.f 429 bytes Ah, it's printing.



next up previous contents index
Next: Editing with vi Up: ViewingEditing, and Previous: More and View