lpd(8)
Name
lpd − line printer daemon
Syntax
/usr/lib/lpd [ −l ] [ −L logfile ] [ portnumber ]
Description
The lpd line printer daemon uses the system calls listen and accept, to receive requests to print files in the print queue, transfer files to the spooling area, display the queue, and remove jobs from the queue.
The line printer daemon is invoked by the /etc/rc command file when the system goes multi-user (normally at system start up). The daemon looks at the /etc/printcap file to find out about the capabilities of existing printers, and prints any files that were not printed when the system last stopped operating.
The Internet port number used to rendezvous with other processes is normally obtained with getservbyname, but can be changed by using the portnumber argument.
Access to the facilities provided by the lpd daemon is controlled by only allowing requests from the machines listed in the /etc/hosts.equiv or /etc/hosts.lpd files. The /etc/hosts.equiv file is described on the hosts.equiv(5yp) reference page. The /etc/hosts.lpd file is a list of names consisting of one host machine name per line. An * character at the start of any line in /etc/hosts.lpd allows print requests from all systems. The machine names listed in the /etc/hosts.equiv and /etc/hosts.lpd files may optionally contain the local BIND domain name. For more information on BIND, see the Guide to the BIND/Hesiod Service.
You can also control access to the lpd daemon by specifying the rs capability for a particular printer in the printcap file. This restricts the printer users to those with accounts on the machine which the printer is connected to.
The file lock in each spool directory is used to prevent multiple daemons from becoming active simultaneously, and to store information about the daemon process for lpr, lpq, and lprm.
After the daemon has successfully set the lock, it scans the directory for command files with names beginning with cf . These files specify names of files which are to be printed and parameters affecting how the files are printed. Each line in a command file begins with a key character to specify what to do with the remainder of the line. The key characters and their meanings are shown below. They are listed in the order that they would appear in a command file.
If a file is to be printed but can not be opened, a message will be placed in the logfile (by default, the system console).
The lpd daemon uses flock to provide exclusive access to the lock file. The lock is automatically removed by the kernel when a lpd process terminates for any reason. The lock file contains two lines. The first is the process id of the daemon and the second is the control file name of the current job being printed. The second line is updated for use by lpq and lprm.
The key characters in the command file and their meanings are as follows:
HhostHost Name. Name of the machine where lpr was invoked.
PuserPerson. Login name of the person who invoked lpr. This is used to verify ownership by lprm.
JjobJob Name. String to be used for the job name on the banner page.
CclassClassification. String to be used for the classification line on the banner page.
LuserLiteral. The line contains identification information from the password file and causes the banner page to be printed.
InumIndent. The number of characters by which the output is indented (in ASCII).
MuserSend mail to the specified user when the current print job completes.
1fontTroff Font R. Name of the font file to use instead of the default.
2fontTroff Font I. Name of the font file to use instead of the default.
3fontTroff Font B. Name of the font file to use instead of the default.
4fontTroff Font S. Name of the font file to use instead of the default.
WnumWidth. Changes the page width (in characters) used by pr and the text filters.
ZnumLength. Changes the page length (in lines) used by pr and the text filters.
Ddata_typeData type of the job.
(PostScript (TM) printers only.)
<input_traySelects the input tray that supplies paper for the print job.
(PostScript (TM) printers only.)
>output_tray
Selects the output tray where the printed paper is deposited.
(PostScript (TM) printers only.)
OorientationSpecifies the orientation of the printed output on the page.
(PostScript (TM) printers only.)
Fpage_sizeSpecifies the size of the pages being printed.
(PostScript (TM) printers only.)
Ssheet_sizeSpecifies the physical size of the sheets being printed.
(PostScript (TM) printers only.)
EmessageSpecifies what happens to messages generated when processing the print job.
(PostScript (TM) printers only.)
XnumSpecifies the number of times each page is printed.
(PostScript (TM) printers only.)
AnumSpecifies the first page to be printed for the job.
(PostScript (TM) printers only.)
BnumSpecifies the last page to be printed for the job.
(PostScript (TM) printers only.)
GnumSpecifies the number of pages to be printed on a single physical sheet.
(PostScript (TM) printers only.)
zfilenameLayup definition file which alters the appearance of pages (margins, borders, etc).
(PostScript (TM) printers only.)
KsidesSpecifies whether the job should be printed on both sides to the physical sheet, and whether the pages should be rotated by 180 degrees.
(PostScript (TM) printers only.)
TtitleTitle. String to be used as the title for pr.
ffilenameFormatted File. Name of a file to print which is already formatted.
pfilenameName of a file to print using pr as a filter.
lfilenameLike f but passes control characters and does not make page breaks.
tfilenameTroff File. The file contains troff.
nfilenameDitroff File. The file contains ditroff output (device independent troff).
dfilenameDVI File. The file contains TeX output (DVI format from Stanford).
gfilenameGraph File. The file contains data produced by plot.
vfilenameThe file contains a raster image.
cfilenameCifplot File. The file contains data produced by cifplot.
rfilenameThe file contains text data with Fortran carriage control characters.
xfilenameDo not interpret any control characters in the file.
UfilenameUnlink. Name of file to remove upon completion of printing.
NnameFile name. The name of the file which is being printed, or a blank for the standard input (when lpr is invoked in a pipeline).
PostScript (TM) Printers With Specialised Support
To use the features of the PostScript (TM) printers for which specialised support is available, you must ensure that :ps=LPS: is set in the appropriate entry in the /etc/printcap file.
For PostScript (TM) printers, the line printer daemon assembles the PostScript (TM) from the users data files and PostScript (TM) device control modules. The device control modules access device features and manipulate the appropriate printer parameters. Device control modules (the Dl capability in /etc/printcap), are provided in an archive file, refer to ar(5). Device control modules access printer specific features of PostScript (TM) and are therefore device dependent.
The data type of the spooled files is given by the Da capability in the printcap file. The data type can be overridden by the D key character in the command file.
The support for PostScript (TM) printers introduces a new method of specifying the type of the data to be printed using the −D option of lpr or the Da capability in /etc/printcap. The mechanism for invoking these translators needs to interact with the existing mechanism for invoking filters for non-text files, so that the existing mechanism can be used if required. The mechanism has the following features:
The new translators are invoked via the shell program xlator_call, which is passed the data type as one of its parameters.
Any old style filter arguments (for example, −t and −x) take precedence over −D (even though lpr will accept the combination). This means that the if capability in /etc/printcap must not be specified if data types are being used.
Filter Capabilities
Two of the printcap capabilities that affect the behaviour of lpd require a more detailed explanation than that given on the printcap(5) reference page.
ctConnection type. This entry in the printcap file determines the type of connection. The following table shows the valid choices for ct, and the mandatory and optional entries to go with each choice.
| ct= | Mandatory Entries | Optional Entries |
| dev | lp | of |
| lat | lp, ts, op, os | of |
| remote | rp, rm | |
| network | of |
Remote means a printer that is connected to another system running a compatible printing daemon. Network means that the output filter does not use stdout (that is, no lp) and is restarted for each job.
uvULTRIX version. To enable the ct capability to determine the type of connection, and to ensure % escapes are expanded in all filter command strings, you must have
:uv=psv1.0:
as part of the printcap entry.
Using Filter Capabilities
This section refers to the programs specified by the following filter capabilities in the printcap file: cf, df, gf, if, nf, of, pp, tf, vf, xf, Lf, and Xf.
Filters may be specified as pipelines as well as simple commands. The syntax accepts tab or space as word separators, and | to set up a pipe connection. You can specify arguments to the filters. The individual commands may be specified as full path names or as simple program names, in which case the path searched is:
/usr/local/lib/lpdfilters:/usr/ucb:/bin:/usr/bin:
/usr/lib:/usr/lib/lpdfilters
Filter Argument Parameterisation
The arguments to the filter program are normally supplied automatically by lpd but you can assign your own arguments to filters. When arguments are supplied automatically, they are put after the arguments for the first command in a pipeline, or after the arguments of a simple command.
If you want to assign your own arguments to filters, you must ensure that :uv=psv1.0: is set in the appropriate entry in the printcap file.
Arguments are supplied exactly as for previous lpd releases unless a special character (%) is found anywhere in the command. If a % is found it tells lpd that you have taken control of passing arguments to the filter. In this case, the default set of arguments are no longer appended to the argument list. The arguments supplied to the command are those specified in the command string, but with lpd replacing %x pairs with parameter strings.
To allow the special character, %, to be passed, a pair of %%’s are replaced by a %. It is an error to specify an unknown %x pair. The %x pairs and the parameter strings that replace them are shown below.
| %x Pairs | Parameter String |
| %% | % |
| %0 | null string (used to pass null argument or disable default arguments) |
| %_ | space (used to insert spaces in arguments) |
| %A | accounting file |
| %D | data type |
| %F | pagesize |
| %H | host where job was submitted |
| %I | indent |
| %j | job name |
| %J | job id as shown by lpq |
| %L | length |
| %O | orientation |
| %P | printer name |
| %T | title |
| %U | user’s login name |
| %W | width |
| %X | pixel width |
| %Y | pixel length |
All of the above %x pairs are available to all input filters. For a network printer (:ct=network: in the /etc/printcap file) they are all available to the output filter of. For dev and lat printers the per-job parameters (%H, %U, %J and %j) are not available to the output filter. This is because the output filter is invoked per session so that per-job parameters are still unset.
Filter Arguments Supplied By lpd
The arguments automatically assigned to each filter by lpd are shown below. For clarity the parameters for each argument are shown as the appropriate %x pair.
| Filter | Parameterised Form of Default Arguments |
| cf | −x%X −y%Y −n %U −h %H %A |
| df | −x%X −y%Y −n %U −h %H %A |
| gf | −x%X −y%Y −n %U −h %H %A |
| if | −w%W −l%L −n %U −h %H %A |
| (when | lpr |
| is invoked | |
| without the −l option) | |
| if | −c −w%W −l%L −n %U −h %H %A |
| (when | lpr |
| is invoked | |
| with the −l option) | |
| nf | −w%W −l%L −n %U −h %H %A |
| of | −w%W −l%L |
| pp | −w%W −l%L −h %T |
| rf | −w%W −l%L −n %U −h %H %A |
| tf | −x%X −y%Y −n %U −h %H %A |
| vf | −x%X −y%Y −n %U −h %H %A |
| xf | (no arguments) |
| Lf | (no arguments) |
| Xf | %D %O %F %W %L %I |
The %A argument is only supplied if the af capability is present.
Options
−lLog valid requests received from the network. This can be useful for debugging purposes.
−Llogfile
Write error conditions to the file specified by the argument logfile. If this option is not used, error conditions are written to the system console.
Files
/etc/printcap Printer description file
/usr/spool/lpd Spool directories
/dev/lp* Line printer devices
/dev/printer Socket for local requests
/etc/hosts.lpd Lists machine names allowed printer access
/etc/hosts.equiv Lists machine names allowed printer access as trusted machines
See Also
lpq(1), lpr(1), lprm(1), printcap(5), lpc(8), pac(8), xlator_call(8)
Guide to the BIND/Hesiod Service
Guide to System Environment Setup