Previous Table of Contents Next


Module 81
lpr (BSD)

DESCRIPTION

The external lpr command spools print jobs to a specific printer's spool queue for later printing by a printer daemon. The printer daemon provides a mechanism for many users to share one device. The daemon knows when the printer is busy and when it is available. The printer queue is a directory with data and control files which make up a print job. The daemon searches for the oldest control file and sends the data file to the printer device based on parameters in the control file.

The system is set up with a default printer destination. If you do not specify a printer destination, your files are sent to the system default. You can override the system default by defining the PRINTER variable in your shell environment. Typically, BSD uses the csh, so the command to set the variable is

     setenv PRINTER lj

For sh and ksh the command is

     export PRINTER=lj

This will cause your files to be printed on the lj printer instead of the system default printer if you do not specify a printer.

If you wish to send a file to a printer other than the system default or your default PRINTER, you simply use the -Pprinter option on the lpr command line.

To list out all available printers type lpc status and press Return. The lpc command is used by the system administrator to control the printer daemons and queues.

COMMAND FORMAT

Following is the general format of the lpr command.

     lpr [ -cdfghlmnprstv ] [ -#num ] [ -1234 font ] [ -C class ]
         [ -J job ] [ -P printer ] [ -T title ] [ -i[num] ] [ -wnum ]
         [ file_list ]

Options

The following list describes the options and their arguments that may be used to control how lpr functions.

The following options are used by lpr to notify the spooling daemon that the input files are not standard ASCII text files. The spooling daemon reads this information from the job control file and uses the appropriate filters to print the data files.

-c Assume the data is output from ciplot.
-d Assume the data is in DVI (Stanford) format.
-f Use a FORTRAN filter which interprets the first character of each line as a standard FORTRAN carriage control character.
-g Assume the data is output from plot routines. The data is in plot format.
-l Uses a filter which displays control characters as ^X and suppresses form feeds (page breaks).
-n Assume the data is output from ditroff (device independent troff).
-p Use pr to format the data (same as the BSD print command).
-t Assume the files contain data from troff (phototypesetter command).
-v Assume the data is raster image format.

The -c, -d, -f, -g, -l, -n, -t, -v require a special filter to work. The system administrator must define each of these filters in the printcap file.

The following options control how lpr performs simple formatting and other functions.

-h Suppresses the printing of the burst (cover) page.
-m Sends mail to you upon completion of the printing.
-r Remove the file after the job has been spooled. If the -s option is used, remove the file after it is has been printed.
-s Use a symbolic link. Usually files are copied to the spool directory. A symbolic link creates a new file with the same name in the spool directory, which is only a link to the original file.
-#num Prints multiple copies of output. Where num is the number of copies of each file to print.
-1234 font Specifies a font to mount in position X, where X is 1 through 4. Fonts are in /usr/lib/vfont. Fonts are vendor or site dependent and printer dependent so trial and error is required.
-Cclass Prints class as a job classification on the burst page.
-Jjob Prints job as the job name on the burst page.
-Pprinter Specifies the destination printer. The output is printed on printer printer.
-Ttitle Forces pr to use title as the head title instead of the file name.
-i[num] Indent the output num columns. If num is not given, the indention is eight spaces.
-wnum Uses num as the page width for pr.

Arguments

The following describes the argument that may be passed to the lpr command.

file_list The list of files to print.
If no files are listed the standard input is printed.

DIAGNOSTICS AND BUGS

If you spool a large file it may be truncated. The size of the file depends on the amount of disk space available in the /usr file system.

Most lpr commands will object to spooling binary files but may not complain about data files. Data files usually cause problems for most printers. If the spooler daemon is not running, lpr will not place jobs in the spool queue unless you are super-user.

RELATED COMMANDS

Refer to the lpq and lprm commands described in modules 80 and 82.

RELATED FILES

The following files are used by lpr.

/etc/passwd Used to identify users
/etc/printcap Printer capabilities database
/usr/lib/lpd* Line printer daemons
/usr/spool/* Directories used for spooling, one for each printer
/usr/spool/*/cf* Job control files
/usr/spool/*/df* Data files specified in the "cf" files
/usr/spool/*/tf* Temporary copies of "cf" files

APPLICATIONS

There is only one reason to use lpr. That is to send files or the standard output of another command to a specific printer connected to your system.

You may want to reference Module 105 on pr to perform simple page formatting and pipe the output to lpr. For example,

     pr -4 file | lpr -Plj

would format the contents of file into 4 columns and send the output to the lj printer.

TYPICAL OPERATION

You must be using a BSD system or a system that supports the BSD lpr command to perform this activity.

In this activity you use the lpr command to send a file to the system printer. Begin at the shell prompt.

1.  Type lpr file1 and press Return. The file named file1 is spooled to the default printer. You can use the lpq command to check the status of your print job.
2.  Type lpq and press Return. Notice the "Rank" of your job. This informs you how many print jobs are ahead of yours in the print queue. The output resembles,
     cj> lpq
     lj is ready and printing
     Rank   Owner      Job  Files               Total Size
     active mylogin    289  file1               199 bytes

NOTE:  
If the default system printer is a high speed printer (1000 lines per minute), your print may not appear in the lpq output, because it has already been printed.



3.  Type lpr -p file2 and press Return to send the file2 file to the default printer. After being processed, pr provides page headers.
4.  Turn to Module 82 to continue the learning sequence.


Previous Table of Contents Next