This section describes the various was that you can communicate with a printer and the support that LPRng provide for them.
The most flexible and highest throughput printer interface is
via a network (TCP/IP) connection.
Most high performance printers have a built in network interface,
or you can attach them to a
printer server
box which provides a network interface.
The network interface usually supports multiple network printing protocols.
The most common are the LPD (RFC1179), Socket API, AppSocket, SMB,
and Novell Netware interfaces.
LPRng directly supports the LPD (RFC1179) and Socket API interfaces,
and you can use the
smbclient program from the
Samba Software Package for the SMB interface.
In this mode of operation the print server actually operates as a very limited BSD print spooler. These limitations include:
For the above reasons, using RFC1179 to transfer jobs to a printer should be regarded as the least desirable option. Please see The RFC1189 Protocol for a detailed discussion of the RFC1179 protocol.
In order to use the RFC1179 transfer operation you must have a printcap entry for the printer that provides:
The following is an example of a simple printcap entry that can be used to send a job to a remote printer using the RFC1179 protocol:
# LPRng syntax
# :lp value is 'where to print the job'
lp:
:lp=raw@10.0.0.1
# OR Vintage BSD Print Spooler Syntax
# (LPRng supports this as well)
# :rp = remote printer, :rm = remote machine or host
lp:
:rp=raw:rm=10.0.0.1
If you wish to transfer jobs to a print spooler without using the
full LPRng lpr program,
the Perl cheap_lpr program
in the LPRng Distribution UTILS directory
can be used for testing and tutorial purposes.
The Socket API is a very flexible job transfer protocol. It is widely support by most Print Server manufacturers, with the Hewlett Packard JetDirect setting the de facto standard. The Socket API is extremely simple.
half-closed,
that is,
the shutdown() network system call is used to indicate to the
remote printer that no further data will be sent,
then the printer may immediately terminate the network connection.
This means that no further network or status messages will be
sent to the user.The following is a sample printcap showing how to use the Socket API:
lp:
# make a socket connection to port 9100
:lp=10.0.0.2%9100
You can use the
netcat
utility by Hobbit <Hobbit@avian.org>
to test that the Socket interface is available and working.
If ellipse.ps is a test file, then:
The simplest and easiest way to print a file to a network printer appears
nc printer.ip.addr 9100 < file
Example:
nc 10.0.0.25 9100 < ellipse.ps
The AppSocket interface is supported by Tektronix and some other printer vendors. It is similar to the Socket API, with a couple of significant differences.
CR/LF
is sent to UDP port 9101, the printer will return a packet to the sender
containing print status information.
This information indicates the printers current status (busy, idle, printing)
and any error conditions.The ihfhp filter,
one of the helper programs for LPRng,
is used with LPRng to provide AppSocket support.
For details,
please see the IFHP HOWTO in the
IFHP Distribution
and
Tektronix P450 and Family for details.
The following is a typical printcap entry for
the AppSocket protocol.
The actual network connection to the printer is made by the ifhp
filter:
lp:
# LPRng opens a dummy connection for consistency
:lp=/dev/null
# we pass the ifhp filter options indicating that the
# Tektronics printer will need the appsocket protocol
# and to use port 35 at 10.0.0.1 to make the connection
# The ifhp filter may open and close the connection several
# times during the file transfer in order to ensure that
# the printer handles the job correctly.
:ifhp=model=tek,appsocket,dev=10.0.0.1%35
:if=/usr/local/libexec/filters/ifhp
A ``network print server'' is usually a box (external model) or card in a printer (internal model) which has a network connection to a TCP network and software to implement a LPD print server. If it is an external model, The parallel or serial port of the printer is connected to the box, and the print server may support multiple printers. If it is an internal model, the server is usually nothing more than a Network Interface Controller and a ROM containing software that the microprocessor in the printer uses.
The print server may support multiple printing protocols, such as RFC1179 (TCP/IP printing using the LPD print protocol), Novell Printer Protocols, SMB print protocols, and AppleTalk protocols. One of the observed problems with Network Print servers is that while they can usually support one protocol and one user at a time quite well, when you try to use multiple protocols and/or multiple users try to transfer print jobs to the printer, the printer may behave in a very odd manner. Usually this results in a printer failing to finish a job currently being printed, and unable to accept new jobs.
Several of the newer models of print servers have Simple Network Management Protocol (SNMP) agents built into them, and can provide detailed information about their internal functions. By using a SNMP manager such as SunNetmanage or HP-Openview, you can monitor your network printers activities.
I recommend that you use only a single protocol to send jobs to the printer. If you can, I also recommend that you use a print spooler and have only a single host system send a job to the printer.
My best advice on connecting to network printers is not to use the the built-in LPD server, but to use the direct TCP/IP connection to the print engine. Usually this is done to particular TCP/IP port on the printer. For the HP JetDirect and other HP products, this is usually TCP port 9100.
Once you have the direct connection, you can now use various filters to preprocess the print job, insert PJL and PCL commands, or convert text to PostScript or PCL for better print quality.
The following is a list of print server manufacturers, models, and with hints on how to access these boxes with various protocols.
|
Manufacturer | Model | RFC1179 Port Name (rp=XXX) | Send to TCP port |
| Digital Products Inc. | NETPrint Print Server | PORTn, where n is port on server | - Unknown if supported - |
| Electronics For Imaging Inc. | Fiery RIP i series | normalq or urgentq | - Unknown if supported - |
| Fiery RIP XJ series | xjprint | - Unknown if supported - | |
| Fiery RIP XJ+ and SI series | print_Model, e.g. print_DocuColor | - Unknown if supported - | |
| Fiery models ZX2100, ZX3300, X2, X2e | print | - Unknown if supported - | |
| Emulex Corp. | NETJet/NETQue print server | PASSTHRU | - Unknown if supported - |
| Extended Systems Inc. | ExtendNet Print Server | Printern, where n is port on server | - Unknown if supported - |
| Hewlett-Packard | JetDirect interface card | raw | 9100 |
| I-Data | Easycom 10 Printserver | par1 (parallel port 1) | - Unknown if supported - |
| Easycom 100 Printserver | LPDPRT1 | - Unknown if supported - | |
| IBM | Network Printer 12, 17, 24, and 24PS | PASS | - Unknown if supported - |
| Lantronix | EPS1, EPS2 | EPS_XXXX_S1 (serial) port 1, EPS_XXXX_P1 (parallel) port 2, etc. | 3001 (port 1), 3002 (port 2), etc. |
| QMS | Various Models | RAW | 35 (Appsocket) |
| Tektronix | Tektronix printer network cards | PS (PostScript), PCL (PCL), or AUTO(Auto-selection between PS, PCL, or HPGL). Not reliable. | 9100 (Appsocket on some models) |
| Rose Electronics | Microserve Print Servers | lp | 9100 |
| Xerox | Models 4505, 4510, 4517, 4520 | PASSTHRU | 2501 (Appsocket on some models) |
| Model 4512 | PORT1 | 10001 (programmable) | |
| Model N17 | RAW | 9100 | |
| Models N24 and N32 | RAW | 2000 | |
| Models 4900, 4915, 4925, C55 | PS | 2000 | |
| Document Centre DC220/230 | lp | - Unknown if supported - | |
All company, brand, and product names are properties of their respective owners.
The HPJetDirect card can be configured through the front panel or through a set of network files. Here is a summary of the methods used from UNIX systems, or when you are desperate, to configure the printer.
You can set the network address from the front panel. Reset the printer, put it in offline mode. and then use the MENU, +-, SELECT keys as follows:
MENU -> MIO MENU (use MENU to display MIO MENU)
ITEM -> CFG NETWORK=NO*
+ -> CFG NETWORK=YES
ENTER -> CFG NETWORK=YES*
ITEM -> TCP/IP=OFF* (use ITEM to display TCP/IP)
+ -> TCP/IP=ON
ENTER -> TCP/IP=ON*
ITEM -> CFG TCP/IP=NO* (use ITEM to display TCP/IP)
+ -> CFG TCP/IP=YES
ENTER -> CFG TCP/IP=YES*
ITEM -> BOOTP=NO*
(Enable BOOTP if you want to - see below)
ITEM -> IP BYTE 1=0*
This is IP address MSB byte.
Use +- keys to change value, and then ENTER to change
Use ITEM keys to get IP BYTE=2,3,4
ITEM -> SM BYTE 1=255*
This is the subnet mask value
Use +- keys to change value, and then ENTER to change
Use ITEM keys to get IP BYTE=2,3,4
ITEM -> LG BYTE 1=255*
This is the Syslog server (LoGger) IP address
Use +- keys to change value, and then ENTER to change
Use ITEM keys to get IP BYTE=2,3,4
ITEM -> GW BYTE 1=255*
This is the subnet gateway (router) IP address
Use +- keys to change value, and then ENTER to change
Use ITEM keys to get IP BYTE=2,3,4
ITEM -> TIMEOUT=90
This is the connection timeout value. It puts a limit
on time between connections. A value of 10 is reasonable.
If you have a bootp server, you can put this information in the bootptab file. To use this, you must enable the bootp option on the printer. The T144 option specifies a file to be read from the bootp server. This file is read by using the TFTP protocol, and you must have a TFTPD server enabled. Here is a sample bootptab entry.
# Example /etc/bootptab: database for bootp server (/etc/bootpd).
# Blank lines and lines beginning with '#' are ignored.
#
# Legend:
#
# first field -- hostname
# (may be full domain name)
#
# hd -- home directory
# bf -- bootfile
# cs -- cookie servers
# ds -- domain name servers
# gw -- gateways
# ha -- hardware address
# ht -- hardware type
# im -- impress servers
# ip -- host IP address
# lg -- log servers
# lp -- LPR servers
# ns -- IEN-116 name servers
# rl -- resource location protocol servers
# sm -- subnet mask
# tc -- template host (points to similar host entry)
# to -- time offset (seconds)
# ts -- time servers
#
# Be careful about including backslashes where they're needed. Weird (bad)
# things can happen when a backslash is omitted where one is intended.
#
peripheral1:
:hn:ht=ether:vm=rfc1048:
:ha=08000903212F:
:ip=190.40.101.22:
:sm=255.255.255.0:
:gw=190.40.101.1:
:lg=190.40.101.3:
:T144="hpnp/peripheral1.cfg":
If you are using the T144 option, you will need to create the configuration file. The sample configuration file from the HP Direct distribution is included below.
#
# Example HP Network Peripheral Interface configuration file
#
# Comments begin with '#' and end at the end of the line.
# Blank lines are ignored. Entries cannot span lines.
# Name is the peripheral (or node) name. It is displayed on the peripheral's
# self-test page or configuration plot, and when sysName is obtained through
# SNMP. This name can be provided in the BOOTP response or can be specified
# in the NPI configuration file to prevent the BOOTP response from overflowing
# the packet. The domain portion of the name is not necessary because the
# peripheral does not perform Domain Name System (DNS) searches. Name is
# limited to 64 characters.
name: picasso
# Location describes the physical location of the peripheral. This is the
# value used by the interface for the MIB-II sysLocation object. The default
# location is undefined. Only printable ASCII characters are allowed.
# Maximum length is 64 characters.
location: 1st floor, south wall
# Contact is the name of the person who administers or services the peripheral
# and may include how to contact this person. It is limited to 64 characters.
# This is the value used by the interface for the MIB-II sysContact object.
# The default contact is undefined. Only printable ASCII characters are
# allowed. Maximum length is 64 characters.
contact: Phil, ext 1234
# The host access list contains the list of hosts or networks of hosts
# that are allowed to connect to the peripheral. The format is
# "allow: netnum [mask]", where netnum is a network number or a host IP
# address. Mask is an address mask of bits to apply to the network number
# and connecting host's IP address to verify access to the peripheral.
# The mask usually matches the network or subnet mask, but this is not
# required. If netnum is a host IP address, the mask 255.255.255.255 can
# be omitted. Up to ten access list entries are permitted.
# to allow all of network 10 to access the peripheral:
allow: 10.0.0.0 255.0.0.0
# to allow a single host without specifying the mask:
allow: 15.1.2.3
# Idle timeout is the time (in seconds) after which an idle
# print data connection is closed. A value of zero disables
# the timeout mechanism. The default timeout is 90 seconds.
idle-timeout: 120
# A community name is a password that allows SNMP access to MIB values on
# the network peripheral. Community names are not highly secure; they are
# not encrypted across the network. The get community name determines which
# SNMP GetRequests are responded to. By default, the network peripheral
# responds to all GetRequests. The get community name is limited to 32
# characters.
#
# For hpnpstat and hpnpadmin, the community name can be stored in
# /usr/lib/hpnp/hpnpsnmp.
get-community-name: blue
# The set community name is similar to the get community name. The set
# community name determines which SNMP SetRequests are responded to. In
# addition, SetRequests are only honored if the sending host is on the
# host access list. By default, the network peripheral does not respond
# to any SetRequests. The set community name is limited to 32 characters.
#
# The set community name can come from /usr/lib/hpnp/hpnpsnmp
# if it is the same as the get community name. We recommend that the
# set community name be different from the get community name though.
set-community-name: yellow
# SNMP traps are asynchronous notifications of some event that has occurred.
# SNMP traps are useful only with network management software. Traps are
# sent to specific hosts and include a trap community name. Up to four
# hosts can be sent SNMP traps. The trap community name is limited to
# 32 characters. The default name is public.
trap-community-name: red
# The SNMP trap destination list specifies systems to which SNMP
# traps are sent. Up to four IP addresses are allowed. If no
# trap destinations are listed, traps are not sent.
trap-dest: 15.1.2.3
trap-dest: 15.2.3.4
# The SNMP authentication trap parameter enables or disables the sending
# of SNMP authentication traps. Authentication traps indicate that an SNMP
# request was received and the community name check failed. By default,
# the parameter is off.
authentication-trap: on
# The syslog-facility parameter sets the source facility identifier that the
# card uses when issuing syslog messages. Other facilities, for example,
# include the kernel (LOG_KERN), the mail system (LOG_MAIL), and the spooling
# system (LOG_LPR). The card only allows its syslog facility to be configured
# to one of the local user values (LOG_LOCAL0 through LOG_LOCAL7). The
# selectible option strings, local0 through local7 (configured to LOG_LOCAL0
# through LOG_LOCAL7, respectively) are case insensitive. The default
# syslog-facility for the card is LOG_LPR.
syslog-facility: local2
# This parameter allows the card to treat hosts on other subnets as if the
# hosts were on the card's subnet. This parameter determines the TCP
# Maximum Segment Size (MSS) advertised by the card to hosts on other subnets
# and affects the card's initial receive-window size. The card will use a
# TCP MSS of 1460 bytes for local hosts, and 536 bytes for a non-local host.
# The default is off, that is, the card will use the maximum packet sizes
# only on the card's configured subnet.
#
# The configuration utility does not allow access to this parameter. If you
# want to configure it, you must manually edit the NPI configuration file
# and add it to the bottom of the entry for the network peripheral.
subnets-local: on
# This parameter affects how the card handles TCP connection requests from
# the host. By default, the JetDirect MPS card will accept a TCP connection
# even if the peripheral is off-line. If this parameter is set to "on", then
# the card will only accept a TCP connection when the peripheral is on-line.
old-idle-mode: off
Microsoft use the SMB (Simple Message Block) protocol to transfer files and print jobs to hosts and printers. SMB can be used over TCP/IP, NetBEUI, IPX, and other lower level network protocols.
Unfortunately, most printers do not provide detailed status or error reports when using the SMB protocol. There are a very large number of printers that have deficient SMB support that causes problems when used in a high traffic or high throughput environment.
It is highly recommended that this protocol not be used unless there is no alternative.
If you have a printer or a remote print spooler that supports
support SMB
You can use the
SAMBA
smbclient program to send a print job to an SMB client.
The following is a sample
Shell Script script which you can use:
#!/bin/sh -x
# This script is an input filter for printcap printing on a unix machine. It
# uses the smbclient program to print the file to the specified smb-based
# server and service.
# The 'smb' printcap entry below shows how to configure LPRng
# for printing
#
# smb:
# :sh:lp=|/usr/local/samba/smbprint
# :sd=/usr/spool/smb:
# :if= ... filter ...
#
# The /usr/spool/smb/.config file should contain:
# server="PC_SERVER"
# service="PR_SHARENAME"
# password="PASSWORD"
#
# Set PC_SERVER to the server, PR_SHARENAME to the printer,
# and PASSWORD to the password for this service.
#
# E.g.
# server=PAULS_PC
# service=CJET_371
# password=""
#
#
config_file=.config
if [ -f $config_file ] ; then
eval `/bin/cat $config_file`
fi
#
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
(
# echo translate
echo "print -"
/bin/cat
) | /usr/local/bin/smbclient "\\\\$server\\$service" \
"$password" -U "$server" -N -P 1>&2
If the above script was in /usr/local/libexec/filters/smbprint,
the printcap entry for this printer would be:
pauls_pc:
:sd=/var/spool/lpd/%P
# we filter the output
:lp=|/usr/local/libexec/filters/smbprint
# you can add filters if you want to do specific actions
:ifhp=model=hp4
:if=/usr/local/libexec/filters/ifhp
The
netatalk
package comes with the
pap program that can be used to transfer jobs using the AppleTalk
protcol.
A printcap entry for a network printer looks like the following:
atalk:
:lp=|/usr/local/atalk/bin/pap -e -p "npbname"
:sd=/var/spool/lpd/atalk
:ifhp=model=ps
:if=/usr/local/libexec/filters/ifhp
The pap program must be
SETUID root and executable only by root or group daemon.
This can be done by using the following script:
cd /usr/local/atalk/bin
chown root pap
chgrp daemon pap
chmod 550 bin
chmod s+u bin
In most UNIX systems the printer port has the name
/dev/lpt,
/dev/prn,
or something similar.
On most systems the
dmesg utility will print a list of IO devices found
during system configuration.
Use the following commands to get the information and scan
for the device.
You should also make sure that the printer device is
available.
dmesg >/tmp/a
grep lp /tmp/a
ls /dev/lp*
Gordon Haverland
<haverlan@agric.gov.ab.ca> supplied this little script,
that will assist with this:
#!/bin/sh
#set -v -x # uncomment for debugging
PATH=/bin:/usr/bin
printer=
for printer in /dev/lp* ;
do
echo PRINTER TEST to $printer 1>&2
for i in 1 2 3 4 5 6 7 8 9;
do
echo PRINTER $printer $i > $printer;
done
echo -e \\r\\f > $printer
done
exit 0;
If your printer is connected to the device name you provided, then you should get a page of something out. If the output suffers from the ``staircase'' effect, you will see the numbers ``marching'' across the page, otherwise the numbers will all be in a single column.
If your printer is attached by a serial line, then you may need to set the serial line characteristics before sending the job to the printer. Here are a set of guidelines to following when attaching a serial port printer to a serial line.
1. Check to make sure that the line is not enabled for login.
Logins are usually managed by the
getty (BSD)
or
ttymon (Solaris, SystemV).
Check your system documentation and make sure that these daemons are not
managing the serial line.
2. Check the permissions and ownership of the serial line. For the most easy testing, set the permissions to 0666 (everybody can open for reading and writing). After you have made sure that you can send jobs to the printer, you might want to change the ownership of the serial line to the LPD server and change the permissions to 0600.
3. Make sure that you can print a test file on the printer via the serial port. This may require setting the line characteristics and then sending a file to the printer. You should try to use 8 bit, no parity, with hardware flow control and no special character interpretation, and definitely no LF to CR/LF translation. The problem is that different versions of UNIX systems have different sets of stty(1) commands to do this. The following simple test script can help in this.
#!/bin/sh
# 9600, no echo, no CR
FLAGS= 9600 -raw -parenb cs8 crtscts
DEV= /dev/tty01
(stty $FLAGS; stty 1>&2; cat $1 ) <$DEV >$DEV
This shows using stty to set the flags, then to print the current settings, and then using cat a file to the output. If you attach a dumb terminal to the serial port, you can even use this script to ensure that input from the device is echoed to the output with the correct speed, parity, etc.
Experience has shown that serially connected printers are the least reliable and lowest speed. Where possible, it is strongly recommended that they be attached to a network print box which will provide a Socket API interface and handle the low level network to serial port protocol conversions.