What if we now want to move one of the two printers
(say lpt2) from node1 to node2?
We have to change the /etc/printcap file
on both nodes. Likewise, we need to change /etc/printcap on
any other network nodes we wished to print from:
- On node1:
lpt1:\
:lp=/dev/par1:sd=/usr/spool/output/lpt1:
lpt2:\
:rm=node2:rp=lpt2:sd=/usr/spool/output/lpt2:
- On node2:
lpt1:\
:rm=node1:rp=lpt1:sd=/usr/spool/output/lpt1:
lpt2:\
:lp=/dev/par1:sd=/usr/spool/output/lpt2:
- On other nodes:
lpt1:\
:rm=node1:rp=lpt1:sd=/usr/spool/output/lpt1:
lpt2:\
:rm=node2:rp=lpt2:sd=/usr/spool/output/lpt2:
Make sure you have entries for node1 and
node2 in the /etc/hosts file on each node.
You also need entries in the /etc/hosts.lpd file on
node1 and node2 for each node that you want
to be able to use the printers.
If you've set up your remote printing network according to
the examples given, you should be able to send a file
in /tmp/test on node2 to the printer attached
to node1 using
a command like this:
lpr -h -Plpt1 /tmp/test
Here's what happens:
- You enter the lpr command to print a file remotely.
- The lpr utility requests printing service.
- The lpd daemon on node2
hears the request, spawns a copy of itself
to service the request, and then creates a spooling subdirectory
to hold the files to be printed.
- The spawned lpd daemon places the print job in
the spooler as two files: a data file containing the file to be
printed and a header file containing information about the print
job (to be printed as an optional front sheet).
- The spawned lpd daemon
processes the spooled print jobs in the order they
were received; it starts sending data packets containing the print
job to the remote lpd daemon.
- The lpd daemon on node1 receives the
packets as a printing request, and after checking that the request
is from an approved node, spawns a copy of itself to service the
request and also creates a spooling subdirectory to hold the files
to be printed. (If the request isn't from an approved source, a
refusal message is sent back to the source address.)
- The spawned lpd collects the data packets, places
the print job into the spooler queue, and then sends the print
jobs, in the order they were received, to the printer you specified.