Much of the flexibility of the LPRng software is obtained from the ability to control the details of each step of job processing. The following section details each step in the processing of a job, and explains the printcap options used to control each operation.
Assume the pr
printcap entry has the form:
pr
:lp=/dev/lp OR :lp=rp@rm
:sd=/var/spool/lpd/pr
:lf=log
:of=/usr/local/bin/lpf
:if=/usr/local/bin/lpf
Assume that we have used the following command to print a set of files.
lpr -Ppr file1 file2
This will create a control file
in the
/var/spool/lpd/pr
directory with the following contents (this is an example -
in practice there may be minor differences between the example
and an actual control file):
Hastart4.astart.com
J/tmp/file1 /tmp/file2
CA
Lpapowell
Ppapowell
fdfA002230astart4.astart.com
N/tmp/file1
UdfA002230astart4.astart.com
fdfB002230astart4.astart.com
N/tmp/file2
UdfB002230astart4.astart.com
Options used:
achk
Accounting check at startaf=
Accounting Filear
Remote printer accounting enabledas=
Accounting at startconnect_grace#
Time between jobsconnect_interval#
Connection intervalconnect_timeout#
Connection timeoutcontrol_filter=
Control file filterff
form feedfo
form feed on openla
Local printer accounting enabledld=
leader on open (initialization string)lk
Lock IO devicelp=
IO device pathnamenb
Nonblocking device opennetwork_connect_grace#
Time between jobsof=
of filterretry_econnrefused#
Retry if open failedretry_nolink#
Retry if open failedrm
the remote machine to send the job torp
the remote print queue to send the job torw
device opened RW flagserver_tmp_dir=
temporary directoryserver_tmp_dir
directory.af
exists,
it is opened (af_fd) and the af_fd is passed as file descriptor
3 to all filters.
If the af
value has the form af=|/program
then the program is started and the program STDIN is used as af_fd.
If the af
value has the form af=host%port
,
then a TCP/IP connection to the corresponding port on the remote host
is made and the port used as af_fd.
In the latter two cases, the filter STDIN (file descriptor 0)
is actually opened read/write, and is used when information is needed
from the accounting filter or remote server.
See
Accounting Printcap Options
for more information on the LPRng accounting support.connect_grace
value is non-zero and the server is opening a device or
network_connect_grace
is non-zero and a network connection
is being made,
the server will pause the specified time.
This is to accommodate devices which need a recovery time between jobs.lp
option is checked to determine the type of IO device.
Format | Meaning |
/pathname | Absolute pathname of IO device |
pr@host | transfer to pr on remote host |
host%port | open a TCP/IP connection to port on host. host can be name or IP address |
|filter | run the filter program; it STDIN will be used as device |
lp
is opened write-only or read-write if the
rw
flag is true, and the resulting file descriptor is io_fd.
If the nb
flag is set,
a non-blocking open will be done as well.
If the lk
(lock device) flag is true,
the device will be locked against use by other LPD servers.host%port
combination,
a TCP/IP connection will be opened to the remote port and the connection will
be used as io_fd.rp@rm
combination,
or none of the above combinations are true and the
rm
and rp
values are non-zero,
then the job will be transferred to a remote printer.
The type of operation will be a job transfer,
rather than printing operation.connect_timeout
value is non-zero,
a timeout is setup for the device or socket open.
If the device or connection open does not succeed within the timeout,
then the open operation fails.connect()
system call)
and the connection attempt fails with an ECONNREFUSED
error,
if the retry_econnrefused
flag is set then the connection attempt is retried,
but this time using an alternative port number.
See
RFC1179 for details.
This is repeated until all of the possible originating port numbers
are exhausted.retry_nolink
flag is set,
then the server will pause for a minimum of
connect_grace
plus a multiple of
connect_interval
seconds
based on the number of attempts
before retrying the open operation.
Note that the interval may increase as the number of attempts
increases.of
filter is specified,
it is created with its STDOUT (fd 1) attached to the io_fd.
Its stdin (of_fd) will be used in the steps listed below.
If there is no
of
filter,
then the of_fd value will be the io_fd descriptor.control_filter
option is specified,
then the program specified by the control_filter
value will be run. It will have its STDIN set to the control file,
and its STDOUT output will be used as the new value of the control file
to transfer to the remote host.
See
Filter Command Line Flags
for details of options passed to the control filter,
and
errorcodes for the exit codes of the filter.la
(local accounting) is true and we are printing a job
or ar
(remote accounting) is true and we are transferring a job,
the as
value is examined.
If it is a filter (program) specification,
then the program is started with its STDIN attached to
/dev/null
and STDOUT to the io_fd,
STDERR to the error file,
and file descriptor 3 to the accounting file descriptor af_fd.
The lpd program will wait until it terminates,
and examine the error code for action, as for the filters
(see
errorcodes below).
If it is a string,
then it is interpreted, the escape sequences replaced with the appropriate
information, and written to the accounting file.achk
(accounting check) flag is set,
a line is read from the accounting filter af_fd file descriptor.
This line should be accept
,
otherwise the job processing terminates with a JFAIL indication.ld
(leader on open) value is provided,
the string
is translated (escapes removed)
and written to the of_fd file descriptor.fo
(form feed on open) flag is true, then the
ff
(form feed) string
is translated (escapes removed)
and written to the of_fd file descriptor.Options used:
ab
Always print banner (default FALSE)be=
End banner generator programbl=
Short banner line formatbp=
Banner generator programbs=
Start banner generatorhl
Banner (header) Lastof=
Banner and File Separator Filtersb
Short banner (default FALSE)sh
Suppress header (banners) (default FALSE)sh
(suppress header) flag is true, no banner is
printed,
and the actions in this section are skipped.hl
(header last) flag is true, the banner is printed at the end
of the job,
and the actions in this section are skipped.lpr -h
then the L
line in the control file will be missing.
This is a signal not to print a banner.
If there is no L
line in the control file
and
ab
(always print a banner) is false
(the default),
then no banner is printed.
If there is no L
line and
ab
is true, then ANONYMOUS is used.bp
, ttbs
,
or be
options.
For historical compatibility,
if the sb
flag is set, then the
bl
(banner line) contents are sent directly to the of_fd;
By default the
bl
value is:
bl=$-'C:$-'n Job: $-'J Date: $-'t
(See
Filter Command Line Flags
for details.)
This will get translated to:papowell:A Job: file1 file2 Date: Thu Nov 27 23:02:04 PST 1997
bs
(start banner) program is specified, then it is used
to generate a banner,
otherwise if the
bp
(banner) program is specified, then it is used
to generate a banner.
If no program is available, we skip the banner generation.
The banner generator program is started with the normal command line
flags
(see
Filter Command Line Flags),
with its STDOUT attached to the of_fd descriptor.
The short banner string described in the previous step is written
to the STDIN.
The banner printer is responsible for generating a banner
appropriate to the printing device.Options used:
Xf=
Format Filterif=
Default F Format Filterpr=
pr formatting programsend_job_rw_timeout=
print job read/write timeout send_query_rw_timeout=
status query operation read/write timeout sf
Suppress FF Print File SeparatorsSequence of Operations: for each job in listed in the control file, the following operations are done in turn.
of
filter present,
the suspend string \031\001
is written to of_fd
and the no further action is taken until the of filter is suspended.p
,
the job is first processed by the program specified by the
pr
program,
and the program output used as the print file.f
,
l
,
or
p
then the if
filter is used,
otherwise the keyword
Xf
is used.
Note that certain formats such as
p, a, l
, may not be used as formats.lf
),
and file descriptor 3 to the accounting fd af_fd.send_job_rw_timeout
value is used.
When doing a status or query operation,
the send_query_rw_timeout
value is used.
If a write or write operation does not complete within
the specified timeout seconds, then we have an error
condition and job processing or the query operation
is terminated with JFAIL status.
If the timeout value is 0, then no timeout is done.lpd
will then wait for the filter to exit.
The exit status can be as follows:
Key Value Meaning
JSUCC 0 Successful
JFAIL 1, 32 Failed - retry later
JABORT 2, 33 Abort - terminate queue processing
JREMOVE 3, 34 Failed - remove job
JHOLD 6, 37 Failed - hold this job
Other Abort - terminate queue processing
of
filter is present,
then it is reactivated with a kill -CONT
signal.sf
(suppress FF print file separators ) is false,
then the
ff
(form feed) string
will be interpreted and sent to the of_fd.Options used:
hl
Header (Banner) LastThe actions taken in this step are identical to those for the
Printing Banner At Beginning,
with the exception that the
be
(end banner program) is used to select the banner generation program
rather than the
bs
(start banner program).
If we have hl
true,
then we print a banner at the end of the job,
rather than start.
Options used:
fq
Form Feed on Closela
Local Printer Accountingtr=
Trailer on Closeae=
Accounting at endsave_when_done
Save when doneSequence of Operations:
fq
flag is set and the
sf
(suppress interfile FF) flag is set,
then the
ff
(form feed) string
will be interpreted and sent to the of_fd.tr
(trailer) string
will be interpreted and sent to the of_fd.la
(local printer accounting) flag is set
or transferring a job and the ar
(remote accounting) flag is set,
the
ae
is examined and accounting is done as described
for the
as field.
of
filter is present,
its STDIN is closed,
and the lpd
server waits for it to exit.
The exit status is used as described above.save_when_done
flag is not specified,
the job is removed.Options used:
mail_from=
Mail from user namemail_operator_on_error=
Mail to operator on errorsend_try#
Maximum Print or Transfer Attemptssave_on_error
Do not delete on errorsend_failure_action=
Action on Failuresendmail=
sendmail path name and optionsstop_on_abort
Stop processing queue on filter abortIf the job processing terminates abnormally, the following sequence of events occurs:
kill -INT
,
kill -QUIT
,
and finally
kill -KILL
operations.mail_operator_on_error
value,
the specified operator will be mailed an error indication.
The sendmail
option specifies the pathname of the
sendmail program and the options needed to have it read
mail addresses from its standard input.
For example, sendmail=/usr/sbin/sendmail -oi -t
is a commonly used set of options.mail_from
value specifies the user name used for
mail origination. If not specified, the default is to use the print spool
queue or printer name.send_failure_action
specified,
then it is decoded and the corresponding action taken.
If the value is
remove
,
hold
,
abort
,
or
retry
,
then the job is removed, held, aborted, or retried.
If the value is |/program
,
the program is executed and
the number of attempts are written to the filter STDIN.
The exit status of the filter will be used to determine the consequent actions.
That is, JSUCC (0) will be success, and the standard success action will
be taken;
JFAIL will cause retry,
JREMOVE will cause the job to be removed,
JHOLD will cause the job to be held,
JABORT or other status will abort processing.stop_on_abort
flag is set,
then further processing of jobs is terminated.
The job is not removed from the queue.save_on_error
flag is clear
then the job is removed from the spool queue.lpd
server will stop processing jobs.send_try
value is 0 or the number of attempts is less than
the send_try
value,
then the job is retried.
Between each attempt to transfer a job to a remote site.
This pause will double after each attempt,
reaching a maximum of max_connect_interval
seconds.
If max_connect_interval
is 0, there is no limit on the interval value.Options used:
lpd_force_poll=
Force LPD to periodically poll print queues lpd_poll_time#
Time between pollsmax_servers_active#
Maximum number of active serversWhen the lpd
server starts,
it will fork a set of subserver processes,
each which will handle an individual queue.
If a system has a large number of queues,
then this forking operation may result in the lpd
server
exhausting the process resources.
To control this, the
max_servers_active
value restricts the number of active
children to the specified value.
If this value is 0,
then 50% of the maximum system processes value will be used.
Due to the limits on the number of processes,
there may be times when a job is placed in a queue,
but the lpd
server is unable to start handling the job.
When all of the children of the main lpd
server have
exited,
the server starts a timer.
After lpd_poll_time
seconds, it will scan the queues,
looking for jobs to process,
and starts a process to service them.
If it does not find any jobs it remains idle.
The lpd_force_poll
flag causes the server to periodically
poll the queues.
This is useful when there is a high possibility that jobs could fail to be
printed due to high loads on the server.