npu Command
The npu (Network Printing Utility) command is normally called from within printer interface scripts created by the Print Management Utility. However, you can also call npu directly from a shell script or a host application.
This topic describes the syntax of the npu command and gives details of the various command line options. It also describes the way in which npu is used within the printer interface scripts.
Syntax
/usr/RCS/bin/npu {options}
Options
-a Forces npu to connect to the printer device before opening the print file. By default, npu opens the print file before attempting to connect (this is to prevent the Reality Despooler timing out before the print file has been opened).
-b bannerSend a banner page, containing specified information, before sending the print file data. banner may be any combination of the following:
%d The printing device (ROUTE-FILE entry name).
%f The print file name.
%h The host machine name.
%p The lp printer name.
%t The time and date.
%u The originator's id.
The -b option should only be used in applications that call npu directly. The lp interface script compiles banner information itself, and Reality supplies its own banner headings with each job.
Note
A banner is also automatically supplied on connections that use the LPR protocol. For details of how to suppress the banner, see the topic Suppressing the LPR Banner.
-c prologue{:name}
Send the specified prologue data to the printer before the print data.
prologue is the full pathname of a prologue definition file, or for short prologue definitions, the definitions themselves. If the name of a prologue definition file is supplied, name must be specified.
name is the name of a section in the prologue definition file.
See Prologue definitions.
-d destinationSpecifies the ROUTE-FILE destination entry for the network printer. If this option is omitted, the print file is sent to stdout.
-e Enables error logging to the file /usr/adm/RCS/NPU_ERROR_LOG.
-F numberSpecifies that one or more form-feed characters are to be appended at the end of the job. number can be any number from 1 to 10. If this option is omitted, no form-feed characters are appended.
-f printFileSpecifies the name of the file to be printed. This may be a regular file or a named pipe. If this option is omitted, data is taken from stdin.
-i secondsSpecifies the number of seconds after which npu will stop waiting for more data from a pipe, and send the data which it has already received to the printing device. If this option is omitted, npu will not send the data until its buffer (512 bytes) is full.
-m mapping{:name}
Substitute characters in the print data.
mapping is the full pathname of a mapping definition file, or for short mapping definitions, the definitions themselves. If the name of a mapping definition file is supplied, name must be specified.
name is the name of a section in the mapping definition file.
See Mapping Definitions.
-p printerSpecifies the printer name used in the lp command. This is used to disable the printer in the lp sub-system should problems occur during communication with the printing device. This option is also used in conjunction with the %p banner option and must be specified if this banner option is used.
-r retriesSpecifies the maximum number of times that npu will retry to connect to the target device, after the initial attempt fails. If this option is omitted, npu will retry forever.
-s Specifies that there should be a delay at the end-of-job between disconnecting from the device and returning control to the calling program. The delay time will be as specified by the -t option or 15 seconds if the -t option is not specified.
-t secondsSpecifies the time in seconds between connection retries. If printer sharing is enabled, this is also used as the end-of-job delay between disconnecting from the printer and handing back control to the calling application. The specified time must be between 1 and 60 seconds, or a default time of 15 seconds is used.
-U Output usage information to stderr and then exit.
-u userIdSpecifies the user-id to be printed by the %u banner option. If this option is not specified, but the %u banner option is, a user-id of npu
is used.
-v Output the npu version number to stderr and then exit.
Exit Codes
The npu program returns the following exit codes.
0 npu has completed successfully.
1 npu could not obtain the routing information from /etc/ROUTE-FILE.
2 npu could not open the specified debug log file for writing.
3 npu pre-connect phase failed.
4 npu connection refused.
5 npu connection failed.
6 npu post-connect phase failed.
7 npu could not open the specified print file for reading.
8 npu pre-send phase failed.
9 npu send phase failed.
10 npu post-send phase failed.
11 npu pre-disconnect phase failed.
12 npu disconnect phase failed.
13 npu post-disconnect phase failed.
14 npu is not enabled.
Keeping a Printer Circuit Open
If a particular application needs to hold a printer circuit open, it should supply the print data via a named pipe and keep the pipe open for as long as the circuit to the printer is required. Such applications should supply their own banner information and end-of-job form-feeds as, typically, the pipe will be open for the duration of many individual print jobs.
Notes:
- While a printer circuit is held open, other users will be unable to print.
- Printer circuits cannot be held open on connections that use the LPR protocol.
Suppressing the LPR Banner
If your printer is connected via a connection that use the LPR protocol, a banner will be automatically supplied. If required, this can be suppressed as follows:
-
Use a text editor to edit the file /etc/ROUTE-FILE.
-
Find the printer's ROUTE-FILE entry. The first line of the entry will have the following format:
name:D:
where name is the system name of the printer's ROUTE-FILE entry. For example:
laser:D:
-
Find the fourth line of the entry. This will appear similar to the following:
:ACI LPR laser:
-
Before the final colon, add the letter
B
preceded by a space. For example::ACI LPR laser B:
-
Close the text editor and save the file.