This document describes how to set up remote printing using the LPR/LPD
protocol at AIX level 4.3.
Related documentation
AIX and related product documentation is also available:
http://www.rs6000.ibm.com/resource/aix_resource
/Pubs/index.html
The basic syntax of remote printing using LPR/LPD is as follows:
AIX 4 allows both local and remote formatting. Local formatting allows a virtual printer to be set up on the local system that will send the data to the remote system with local headers and printer setup information attached. Remote formatting sends the data to the remote server without doing any filtering or formatting of the file and without adding any printer setup commands.
smit mkpq
Reasons why you may consider setting up a local queue that uses an AIX virtual printer follow:
There are two steps to setting up an LPD print server on AIX. The first step is to start the lpd daemon on AIX.
ps -ef | grep lpd 3
NOTE: The command lssrc -s lpd can also be used for step 10.
grep <hostname> /etc/hosts.lpd
NOTE: To allow all hosts to print to your server, enter a "+" symbol in the /etc/hosts.lpd file.
With normal processing, the filename is passed to the AIX lpr program (rembak), which sends the file to the remote lpd server without making any changes or additions to the file. When setting up a remote queue with local formatting, the backend program is /usr/lib/lpd/pio/etc/piorlfb. In addition to creating the queue, a virtual printer is also created. You can see the virtual printer file in the /var/spool/lpd/pio/@local/custom directory. You can also make changes to the virtual printer through option 2 in the SMIT shortpath smitty chpq after selecting the queue name. If you examine the piorlfb shell script you will see that it pipes the file to piobe (the virtual printer backend), and the output is redirected to a temporary file in /var/tmp/, starting with piorlfb_. This filename is then given to rembak which sends the formatted file to the remote print server. The output that is created is identical to that which would be created for a local printer on the AIX client.
The following list shows the entry in /etc/qconfig for a locally formatted remote queue:
asc: device = @tesch host = tesch rq = asc s_statfilter = /usr/lib/lpd/bsdshort l_statfilter = /usr/lib/lpd/bsdlong @tesch: header = never trailer = never access = both backend = /usr/lib/lpd/pio/etc/piorlfb -f ! -T5
The SHORT FORM FILTER (and LONG) are simply shell scripts that format the status information coming back from the client to the server.
The values of aixshort and aixlong are only used when connecting from one AIX system to another. When connecting PC's, 3rd Party UNIX systems, Novel flexip, or some terminal servers, this can be changed to either bsdshort or attshort depending on the type of lpd daemon on the server system.
Examples of the status format are shown in Remote printing status.
In addition to formatting the status output, the value of the flags is also used by rembak in deciding which print flags to use.
In the LPD protocol, flags are sent to the remote system in a portion of the transmission called the control file. This file can be read by using iptrace. The flag values are also recorded in the debug output of both rembak and lpd as described in the Problem determination section below.
00000000 48616978 34707274 0a50726f 6f740a66 |Haix4prt.Proot.f| 00000010 64664134 36366169 78347072 740a5564 |dfA466aix4prt.Ud| 00000020 66413436 36616978 34707274 0a4e2f76 |fA466aix4prt.N/v| 00000030 61722f74 6d702f70 696f726c 66625f31 |ar/tmp/piorlfb_1| 00000040 36393534 0a2d6f2d 640a2d6f 700a2d6f |6954.-o-d.-op.-o| 00000050 2d6a0a2d 6f300a2d 6f2d4a0a 2d6f300a |-j.-o0.-o-J.-o0.| 00000060 2d6f2d5a 0a2d6f30 0a2d4e31 0a2d5a72 |-o-Z.-o0.-N1.-Zr| 00000070 6f6f7440 61697834 7072740a 2d74726f |oot@aix4prt.-tro| 00000080 6f744061 69783470 72740a2d 542f7661 |ot@aix4prt.-T/va| 00000090 722f746d 702f7069 6f726c66 625f3136 |r/tmp/piorlfb_16| 000000a0 3935340a |954. &nbsThe flags in the control file can be divided into two groups:
The first few flags in the control file above are flags from the standard:
The actual content of this control file and the flags that are passed between systems depends on several things:
Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --- --- gena @tesc READY <---- client queue gena, queue device @tesch gena genas DOWN <---- server queue genasc, queue device lpx QUEUED 167 STDIN.22612 root QUEUED 170 /etc/motd root@aix4pThe exact format of the remote status will depend on the type of LPD running on the server as well as the stat filter set up in the client queue.
In the case above, The local (client) queue is empty and shows that the data has already been passed to the remote queue, which is down. The queue on the remote (server) system also has a job #167 that was sent locally on the server.
The following output comes from an IBM Network Printer using a bsdshort filter.
# lpstat -vbsdtest
Queue Dev Status Job Files User PP % Blks Cp Rnk
------- ----- --------- --- ------------------ ---------- ---- -- ----- --- ---
bsdtest @9 READY
bsdtest: 1 entries
bsdtest: 0 - port busy. No info
The same printer using the attshort filter shows:
# lpstat -vbsdtest
Queue Dev Status Job Files User PP % Blks Cp Rnk
------- ----- --------- --- ------------------ ---------- ---- -- ----- --- ---
bsdtest @9 READY
0 0 1 1 1 0 Unknown entries
0 Unknown - 0 0 1 1 2
The queue name for both lines of the status will show the client queue name as the name, but the Device will show the client device (usually the server name), for the local status line and the server queue name for the device name of the remote queue status line.
NOTE: Only five characters of the device name will display.
#lpstat -vteschasc Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --- --- teschas @tesc READY <---- client queue teschasc:@tesch teschas asc READY <---- server queue asc:lp0 asc lpxt READY <---- server queue asc:lpxtNote that the third line (the second queue device on the server queue) has the queue name of the server queue.
iptrace -p 515 -a -b -s client -d server /tmp/trace.file
echo "AAAAA" | qprt -Premque
ps -ef | grep iptrace kill PID
ipreport -n /tmp/trace.file > /tmp/trace.report
# grep 0000 /tmp/aaaaa.rpt 00000000 036a756e 6b0a |.junk. | 00000000 30373831 2d323032 20796f75 7220686f |0781-202 your ho| 00000010 73742064 6f657320 6e6f7420 68617665 |st does not have| 00000020 206c696e 65207072 696e7465 72206163 | line printer ac| 00000030 63657373 2e |cess. |
The following is an example of a good print job: Note that it shows the
file size (6), the temporary filename (dfA329tesch), the actual
data in the file (AAAAA), the control file size (96), the
control file temporary name (cfA329tesch), and the control file
with the flags.
00000000 00 |. |
00000000 03362064 66413332 39746573 63680a |.6 dfA329tesch. |
00000000 00 |. |
00000000 41414141 410a |AAAAA. |
00000000 00 |. |
00000000 00 |. |
00000000 02393620 63664133 32397465 7363680a |.96 cfA329tesch.|
00000000 00 |. |
00000000 48746573 63680a50 726f6f74 0a666466 |Htesch.Proot.fdf|
00000010 41333239 74657363 680a5564 66413332 |A329tesch.UdfA32|
00000020 39746573 63680a4e 53544449 4e2e3231 |9tesch.NSTDIN.21|
00000030 3736300a 2d4e310a 2d5a726f 6f744074 |760.-N1.-Zroot@t|
00000040 65736368 0a2d7472 6f6f7440 74657363 |esch.-troot@tesc|
00000050 680a2d54 53544449 4e2e3231 3736300a |h.-TSTDIN.21760.|
00000000 00 |. |
00000000 00 |. |
When you create or modify a remote queue, you can specify the log file
in the line:
To turn on debugging, specify output [/tmp/testdbg.log]
file pathname
This adds the -D flag to the backend line as shown below:
backend = /usr/lib/lpd/rembak -D /tmp/testdbg.log
The following example shows how you would add a new queue with this option:
Add a Standard Remote Print Queue Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] * Name of QUEUE to add [testdbg] * HOSTNAME of remote server [9.19.169.54] * Name of QUEUE on remote server [junk] Type of print spooler on remote server AIX Version 3 or 4 + Backend TIME OUT period (minutes) [] # Send control file first? no + To turn on debugging, specify output [/tmp/testdbg.log] file pathname DESCRIPTION of printer on remote server []
When a file is printed, the output in the file will include information
on the control file, the size of the job and other useful information. The following
shows a sample file:
rembak[42216] main: Thu Feb 1 12:48:35 2001
rembak[42216] main: /usr/lib/lpd/rembak -D /tmp/testdbg.log -S 9.19.169.54 -P junk -N \
/usr/lib/lpd/aixshort /etc/motd
rembak[42216] main: backend=1.
rembak[42216] hookup: Try to connect, current time=981053315.
rembak[42216] sendjob: sendjob starts, jobname=/etc/motd, current time=981053315.
rembak[42216] sendjob: datafn[0]=dfA330tesch, fakedfn=dfA330tesch.
rembak[42216] makecontrolfile: Entering makecontrolfile.
rembak[42216] makecontrolfile: dfnames[0]=dfA330tesch
rembak[42216] getbsdinfo: bsd3=Htesch\10 Proot\10
rembak[42216] get_bsd_4file: bsd nc=1
rembak[42216] get_bsd_4file: bsd strings: [N/etc/motd\10 ][N/etc/motd\10 ]\
[N/etc/motd\10
][N/etc/motd\10 ]
rembak[42216] getbsdinfo: bsd3=Htesch\10 Proot\10 fdfA330tesch\10 UdfA330tesch\10 \
N/etc/motd\10
rembak[42216] gettmpr: Opening file /tmp//rembak1EFo7a.
rembak[42216] gettmpr: File /tmp//rembak1EFo7a opened successfully, fd=8.
rembak[42216] sendjob: ctrlfname=/tmp//rembak1EFo7a, fakecfn=cfA330tesch.
rembak[42216] sendjob: State machine starts.....
rembak[42216] sendjob: State 1 - send the "Receive a Print Job" request.
rembak[42216] sendreq: sendreq - sending lpd request [\2 junk\10 ].
rembak[42216] gotack: Reading ACK status.....current time=981053315, timeout_ack=90.
rembak[42216] gotack: ACK status=0x0.
rembak[42216] sendjob: state 3 - Send data file(s), dfcount=1.
rembak[42216] sendjob: realfn=/etc/motd, fakefn=dfA330tesch, \
filter=/usr/lib/lpd/aixshort.
rembak[42216] sendreq: sendreq - sending lpd request [\3 880 dfA330tesch\10 ].
rembak[42216] gotack: Reading ACK status.....current time=981053315, timeout_ack=90.
rembak[42216] gotack: ACK status=0x0.
rembak[42216] senddatafile: Opening file /etc/motd.
rembak[42216] senddatafile: File /etc/motd opened successfully, fd=9.
rembak[42216] send_file_rembak: Reading 880 bytes from file, fd=9.
rembak[42216] send_file_rembak: Writing 880 bytes to socket 7.
rembak[42216] send_file_rembak: File sent.
rembak[42216] ack: Send ACK.
rembak[42216] send_file_rembak: waiting for ACK.
rembak[42216] gotack: Reading ACK status.....current time=981053315, timeout_ack=90.
rembak[42216] gotack: ACK status=0x0.
rembak[42216] sendjob: State 2 - send control file, ctrlfname=/tmp//rembak1EFo7a, \
fakecfn=cfA330tesch.
rembak[42216] sendreq: sendreq - sending lpd request [\2 92 cfA330tesch\10 ].
rembak[42216] gotack: Reading ACK status.....current time=981053315, timeout_ack=90.
rembak[42216] gotack: ACK status=0x0.
rembak[42216] sendcontrolfile: Opening file /tmp//rembak1EFo7a.
rembak[42216] sendcontrolfile: File /tmp//rembak1EFo7a opened successfully, fd=9.
rembak[42216] send_file_rembak: Reading 92 bytes from file, fd=9.
rembak[42216] send_file_rembak: Writing 92 bytes to socket 7.
rembak[42216] send_file_rembak: File sent.
rembak[42216] ack: Send ACK.
rembak[42216] send_file_rembak: waiting for ACK.
rembak[42216] gotack: Reading ACK status.....current time=981053315, timeout_ack=90.
rembak[42216] gotack: ACK status=0x0.
rembak[42216] sendjob: State 5 - end of job #330 (/etc/motd).
rembak[42216] sendjob: Delete control file /tmp//rembak1EFo7a.
From the preceding example, you can see the entire process, from the
command sent to rembak to the deletion of the temporary file.
To use lpd debug you must enable the output in the /etc/syslog.conf file as well as turn on the debug flag for lpd.
Follow these steps:
*.debug /tmp/lpd.log
# touch /tmp/lpd.log
# refresh -s syslogd
Follow these steps to turn on lpd debug:
# stopsrc -s lpd
# smitty lpd
Start the Print Server Subsystem Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] Start subsystem now, on system restart, or both [both] TRACE lpd daemon activity to syslog? [yes] EXPORT directory containing print attributes? [no]
The following example shows the status and a print job:
# cat /tmp/nslddbug.log
Feb 1 13:11:19 tesch syslogd: restart
Feb 1 13:11:36 tesch lpd[45316]: 0781-205 request displayq short asc.
Feb 1 13:12:16 tesch lpd[45320]: 0781-205 request recvjob asc.
To view more detailed output, enter the following:
# stopsrc -s lpd # startsrc -s lpd -a "-d -l -D /tmp/lpd.dbug"
Printing a job after entering the preceding commands shows a file similar to the following:
lpd[6726] main: Thu Feb 1 13:21:20 2001
lpd[6726] main: /usr/sbin/lpd -d -l -D /tmp/lpd.dbug
lpd[42086] main: child process starts.....
lpd[42086] doreq: lpd command=[\2 asc].
lpd[42086] doreq: (WARNING) 0781-205 request recvjob asc.
lpd[42086] readjob: send ACK.
lpd[42086] readjob: lpd command=[\3 880 dfA558aix4prt].
lpd[42086] readjob: CmdType 3 - receive data file.
lpd[42086] chk_request: Entering chk_request, rq_str=[880 dfA558aix4prt].
lpd[42086] chk_request: rc=2, filename=dfA558aix4prt, *psize=880.
lpd[42086] chk_request: Opening file dfA558aix4prt.981055283.
lpd[42086] chk_request: Clearing file dfA558aix4prt.981055283, *psize=880.
lpd[42086] chk_request: send ACK.
lpd[42086] readfile: Entering readfile, file=dfA558aix4prt.981055283, size=880.
lpd[42086] readfile: Opening file dfA558aix4prt.981055283.
lpd[42086] readfile: File dfA558aix4prt.981055283 opened successfully, fd=7.
lpd[42086] readfile: Reading 880 bytes from socket, fd=1.
lpd[42086] readfile: Writing 880 bytes to file, fd=7.
lpd[42086] noresponse: Read ACK status byte, current time=981055283.
lpd[42086] noresponse: ACK status byte=0x0.
lpd[42086] readfile: send ACK.
lpd[42086] readjob: lpd command=[\2 120 cfA558aix4prt].
lpd[42086] readjob: CmdType 2 - receive control file.
lpd[42086] chk_request: Entering chk_request, rq_str=[120 cfA558aix4prt].
lpd[42086] chk_request: rc=2, filename=cfA558aix4prt, *psize=120.
lpd[42086] chk_request: Opening file cfA558aix4prt.981055283.
lpd[42086] chk_request: Clearing file cfA558aix4prt.981055283, *psize=120.
lpd[42086] chk_request: send ACK.
lpd[42086] readfile: Entering readfile, file=cfA558aix4prt.981055283, size=120.
lpd[42086] readfile: Opening file cfA558aix4prt.981055283.
lpd[42086] readfile: File cfA558aix4prt.981055283 opened successfully, fd=7.
lpd[42086] readfile: Reading 120 bytes from socket, fd=1.
lpd[42086] readfile: Writing 120 bytes to file, fd=7.
lpd[42086] noresponse: Read ACK status byte, current time=981055283.
lpd[42086] noresponse: ACK status byte=0x0.
lpd[42086] readfile: send ACK.
lpd[4206] doit: cfn=[cfA558aix4prt.981055283].
lpd[4206] doit: get a line [Haix4prt].
lpd[4206] doit: get a line [Proot].
lpd[4206] doit: get a line [fdfA558aix4prt].
lpd[4206] doit: get a line [UdfA558aix4prt].
lpd[4206] doit: get a line [N/etc/motd].
lpd[4206] doit: get a line [-o-z].
lpd[4206] doit: get a line [-o+].
lpd[4206] doit: get a line [-o-Y].
lpd[4206] doit: get a line [-o1].
lpd[4206] doit: get a line [-N1].
lpd[4206] doit: get a line [-Zroot@aix4prt].
lpd[4206] doit: get a line [-troot@aix4prt].
lpd[4206] doit: get a line [-T/etc/motd].
lpd[4206] doit: exec enq cmd=[/usr/bin/enq -Pasc -r -troot@aix4prt -Zroot@aix4prt -N1 \
-T/etc/motd -o-z -o+ -o-Y -o1 /var/spool/lpd/dfA558aix4prt.981055283 ].
lpd[42086] readjob: No more commands, rc=0, ck=3.
lpd[42086] main: child process stops
Two important pieces of information are the flags in the doit: get a line
lines and then the enq flags in the exec line.
You will only want to run lpd in this mode for a short time. After you have gathered the information, stop and restart the lpd daemon, enter:
# stopsrc -s lpd # startsrc -s lpd
You will not be able to print remotely if you cannot print locally.
Ensure that the name and address of the client system is in the file /etc/hosts of the server system and vice versa. This is not necessary if you are running a name server. If the client cannot look up the host by name, rembak will fail and the queue will go down.
Test to see if each hostname is accessible with the host or nslookup command.
host <hosta> host <hostb> nslookup <hosta> nslookup <hostb>Prior to setting up the remote queue on hosta, ensure that a local queue has been setup on hostb. For this example, assume the queue name on hostb is asc1.
Print to the queue asc1 while logged into hostB, by issuing the command:
lpr -Pasc1 <filename>To be able to print from the client hostnameA to the printer lp51, you will need to accomplish the steps in the following example.
In this example we have a local queue named text on the server and a remote queue remtext on the client.
# disable text
# disable remtext
# qprt -Premtext /full_path/filename
# lpstat -vremtext
# qchk -PremtextThis should now show both queues as DOWN, and the job queued on the local client.
# enable remtext
# qchk -PremtextThe remtext should show READY, and the remote queue should show DOWN with a job queued.
# ls -l /var/spool/lpdExample output follows:
total 6264 -rw-rw-rw- 1 root system 1011513 Jan 29 15:43 asc32 -rw-rw-rw- 1 root system 1011513 Jan 29 15:48 asc33 -rw-rw-rw- 1 root system 1011513 Jan 29 15:50 asc34 -rw-r----- 1 lpd printq 880 Feb 01 13:20 dfA557aix4prt.981055243 drwxrwxr-x 3 root printq 512 Apr 28 2000 pio drwxrwxr-x 2 root printq 166912 Feb 01 13:21 qdir drwxrwxr-x 2 root printq 1536 Feb 01 13:12 stat
# cp /var/spool/lpd/dfA557aix4prt.981055243 /tmp/testfile
# cat /var/spool/lpd/qdir/n0*This will show the flags for the job. The file will end with something similar to the example below. The line that starts with -Ptext shows the flags that are enq valid flags. The flags below, that start with $#@! are -o flags for enq. The last line in the file is the temporary filename.
-Ptext-r-troot@aix4prt-Zroot@aix4prt-N1-T/etc/motd /etc/motd root@aix4prt tesch 0 $#@!-z $#@!+ $#@!-Y $#@!1 /var/spool/lpd/dfA558aix4prt.981055283 1
# enable text
If the job printed, it could be a timing issue. If the job didn't print, continue to step 12.
-Ptext-r-troot@aix4prt-Zroot@aix4prt-N1-T/etc/motd $#@!-z $#@!+ $#@!-Y $#@!1The -t and -Z flags are not really important in this test. The enq flag to use is:
enq -Ptext -r -N1 -T/etc/motd -o -z -o + -o -Y -o 1 /tmp/testfile
Prior to AIX 4.3, the AIX printing subsystem always sent the data file before the control file. This means that when you print to network print servers, if the file is too large, all the data may not be sent before the devices buffer runs out. An update to RFC 1179 describes some new subcommands to the print command that allow the control file to be sent before the print job or to send a print job of unspecified length. These functions are implemented in the AIX 4.3 operating system. When adding a remote queue through SMIT, the additional options Send control file first has been added to the menu. The default is still no, but for network print servers this can be changed to yes.
The advantage of streaming LPR/LPD is that the print server has enough information as soon as it starts receiving data to print the data without waiting for the entire data file to arrive before starting the print job. This means that jobs of essentially unlimited length can theoretically be printed to devices that support this.
When AIX receives jobs as the print server, it can also receive jobs with the control file first, but because of the way that the qdaemon is implemented, the entire file must still be placed in /var/spool/lpd before the job can be submitted to enq to create the job description file and start the job printing to the local printer. This basically means that streaming works fully when AIX is the client, but only partially when AIX is the server.
NOTE: The -R flag is not supported when sending a request to an AIX system. The lpd daemon in AIX does not support such a request. The -R flag is supported only for compatibility with other systems.
NOTE: The queuing system does not support multibyte host names.
To use the -X flag on a remote queue, the following line for the specific queue must be included in the /etc/qconfig file:
backend = /usr/lib/lpd/rembak -X
The qprt, lpr and other queuing commands are not guaranteed to work when -X is specified on a queue. Use the enq command.
rembak -S olive -P popeye -N /usr/lib/lpd/aixv2short spinach asparagus broccoli
rembak -S olive -P popeye -N /usr/lib/lpd/aixv2short -L
rembak -S olive -P popeye -N /usr/lib/lpd/aixv2short -x -#23 -u sweetpea@bluto
/usr/lib/lpd/rembak -S rhost -P rqueue -x -# 123 -u userid@hostYou must know the following:
This will allow you to kill any job that is in a queue - if it was submitted
from a remote queue. You only need to be root on a system that has line
printer access on the system where you want to cancel the job.
[ Doc Ref: 98138723625152 Publish Date: Feb. 22, 2001 4FAX Ref: 10113 ]