Basic Command-Line Printing


The lpr command is used to send a file to the print spooler. At its simplest, lpr takes the form:

# lpr filename


where filename is, naturally, the name of the file that should be printed. You can specify multiple filenames on the command line to cause multiple files to be printed.

You have the option of specifying a printer to which you want the data to be sent; to do so, use the -P option. If you omit the -P option, lpr assumes that the default printer should be used. The default printer is determined by checking these conditions in the following listed order; the first condition that is found to be true will be used to define the default printer:

  • If the PRINTER environment variable is set, lpr will use the name listed here as the default printer.

  • If the LPDEST environment variable is set, lpr will use the name listed here as the default printer.

  • The printer name lp is used, which should be an alias to one of the printers in the /etc/printcap file.

  • If neither the PRINTER environment variable nor the LPDEST environment variable is set, and no printer has an lp alias in /etc/printcap, the print request will fail.

The lpr command also has several other options. Table 17.3 contains a list of some of the options you are likely to find the most useful.

Table 17.3. Options to the lpr Command

Option

Description

-l

Uses a filter that will print control codes and suppress page breaks.

-p

Output is formatted with pr, which formats pages into 66 lines per page with a header at the top containing the date and time the file was created, along with the page number and five blank lines at the bottom.

-P

Sends the job to a printer other than the default one.

-h

Suppresses the printing of the "burst" page, also known as the banner or header page. This has no effect if header pages are turned off by default.

-m

Sends email to you, notifying you when the print job has completed printing.

-r

Removes the file upon completion of spooling. This option should probably not be used because it will remove the file before it has successfully printed. If it is used with the -s option (described next), it won't remove the file until after it has completed printing.

-s

Uses symbolic links. Rather than copying the file to the spool directory, this option will simply create a symbolic link to the spool directory from the existing file. This allows files too large to fit in the spool area to be printed. If you use this option, be careful that you do not modify or delete the file before it has finished printing.

-#n

Here, n is the number of copies of each file that should be printed. (This feature can be disabled.)

-J job

Here, job is the name of the job that should be printed on the banner page. By default, it will be the name of the first file that is specified.

-T

Specifies the title string that pr should use on the header at the top of the page. By default, this will be the filename. This option only applies if the -p option has also been used.

-i n

Here, n represents the number of columns by which the printed output will be indented.

-w n

Here, n represents the page width in columns. This only applies if the -p option has also been used.





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net