xtlhp - hpnpf protocol server driver
xtlhp -h hostname -p port [ -d n ] [ -f file ] [ -c file ] [ -l log ] [ -b blksize ] [ -c community ] [ -T timeout ] [ -S snmp ] [ -D n ]
xtlhp is a terminal server program for use by GNUspool where the destination is an HPNPF server. Alternatively other printer devices which accept input using ``reverse telnet'' and allow status to be interrogated via SNMP (or other means) may be driven.
After each block is transmitted, the status of the printer is interrogated using a supplied control script.
Versions of xtlhp after 23.6 perform SNMP operations directly, rather than relying on an external program being available.
This is the host name or IP address to be used to access the
printer. In GNUspool setup files, it may be appropriate to
substitute $SPOOLDEV
or $SPOOLPTR
here.
This is the port number or service port name to be used.
This is the location of the definitions file, if not xtsnmpdef in the GNUspool internal programs directory.
Specifies a control file for obtaining the printer status. See the CONTROL FILE section below.
Specify error message destination if not standard error.
Specify output block size. n may be a number, or followed by b, k, m or g to denote blocks, kilobytes, megabytes or gigabytes.
Otherwise a default block size of 10K is assumed.
Debug. Displays activities on standard error, if n is greater than zero. Higher values of n will give more output, including tracing of SNMP operations.
As for -d, except that no output is attempted, the control script is executed once only and the appropriate exit code returned. Use an argument of zero to just invoke the script and exit.
Specify the community in SNMP operations. The default is public.
Specify the timeout to wait for SNMP replies. The default is 1 second, but the value given may be fractional.
Specify the SNMP port name to use, if not snmp
.
The configuration file xtsmnpdef provides a series of mnemonics for the SNMP definition of the form:
system 1.3.6.1.4.1.11.2 gdStatusBytes system.3.9.1.1.1
The function of these definitions is to ``macrogenerate'' constructs which appear in the control file, for example (with appropriate definitions)
gdStatusPaperOut.0
may be used as an abbreviation for
1.3.6.1.4.1.11.2.3.9.1.2.8.0
Previous versions of xtlhp expected quotes around the columns of the file, but this is no longer expected. The file may define names in terms of previously-defined names and may redefine names. If a name is redefined, names already defined using the previous definition are unaffected.
The control file consists of a series of command structures involving options to obtain SNMP values, run commands, string and numeric comparisons and assignments.
Constructs are based upon the shell, but control names are in upper case.
A single-quoted string is taken literally, as per the shell.
A string enclosed in double-quote characters is subject to name expansions of macros defined in the configuration file and variables assigned in the script.
SNMPVAR(objid)
The specified objid, which may be specified using macros, is returned, treated as a numeric value.
SNMPSTR(objid)
The specified objid, which may be specified using macros, is returned, treated as a string value.
A back-quoted string is a shell command to execute and the output taken as a string. Variable names are expanded within the string before execution.
A string enclosed in square brackets is a shell command to execute, with the output taken to be a decimal numeric value, the whole returning a numeric value. Variable names are expanded within the string before execution.
A string enclosed in braces is a shell command to execute, with the
output assumed to be a hexadecimal value. (This is required for
snmpinfo(8)
on AIX systems, which returns hexadecimal values).
Variable names are expanded within the string before execution.
a numeric value.
The value currently assigned to name, if any, is the value of the expression.
The last SNMP value obtained (possibly using DEFINED
or
UNDEFINED
) as a numeric or string value.
The following constructs or ``statements'' are used in the control file.
Assignment, as in
X = "ABC"
The value on the right is assigned to the name on the left.
One time assignment. As per assignment, but the operation is turned into a no-op after the first execution.
For example
Host = `hostname`
would be evaluated each time the script is run (after every block), but
Host := `hostname`
would only be evaluated the first time.
Comparison of strings is performed with alphabetic operators LT, LE, EQ, NE, GE and GT, and numerics with symbolic operators < etc.
DEFINED(objid)
Return a true value if the given object id (which may be specified using macros) is defined, otherwise false. If the value is defined, LASTVAL is set to whatever value that was to save further fetches.
UNDEFINED(objid)
As for DEFINED but the other truth value is returned. LASTVAL is still set if the value is defined.
Return a true value if the value is a number.
Return a true value if the value is a string.
Combine boolean operations in tests. AND is more binding than OR. ``Short circuit'' evaluation is performed, so beware of relying on LASTVAL.
Conditional construct with optional ELIF and ELSE parts.
Display message on standard error.
Exit xtlhp with specified exit code (from 0 to 255).
Send flush command (ESC-E) to socket.
This is the control file supplied by default, with definitions for
gdStatusLineState
etc being provided in the definitions file
supplied.
Note that if no EXIT appears, then script file has ``succeeded'' and output continues.
# Test the status to see if there are problems
IF SNMPVAR(gdStatusLineState.0) != 0 THEN # Look at paper out indication and exit # message
IF SNMPVAR(gdStatusPaperOut.0) != 0 THEN MSG 'Out of paper' EXIT 100
# Likewise paper jam
ELIF SNMPVAR(gdStatusPaperJam.0) != 0 THEN MSG 'Out of paper' EXIT 101
# Likewise toner low
ELIF SNMPVAR(gdStatusTonerLow.0) != 0 THEN MSG 'Out of toner' EXIT 102
# Give up just give general message
ELSE MSG SNMPSTR(npSysStatusMessage.0) EXIT 103 FI FI
xtlhp generates any appropriate diagnostics on standard error.
Normal termination is denoted by an exit code of zero.
Most of the other exit codes are determined by the control file and can be adjusted by the user as required.
Usage error, invalid option etc.
Device error, cannot connect socket etc.
System error.
SNMP error.
xilp(8), xtelnet(8), xtftp(8), xtlpc(8).
John M Collins, Xi Software Ltd.