Sidebar: Setting Up a Remote Printer in UNIX with lp
When a print request is sent to a UNIX printer, the
name of the print
file is passed as an argument to what UNIX calls a printer
interface
file. In SCO UNIX 3.4.2, this file resides in the /usr/spool/lp/admins/lp/interfaces
directory. A printer interface file exists for each
printer defined
on the system.
The printer that I was setting up didn't really exist
for the UNIX
machine; it was a local printer to a PC out on the network.
I needed
to find a way to set up the printer in UNIX. Normally
SCO handles
remote printers via its LPR/LPD print utilities rather
than the standard
lp command. Since we could not find a version of LPR/LPD
that
worked correctly with Windows for Workgroups, we decided
to use remote
copy, rcp, to copy the print file over to the remote
PC. Once
the print file was successfully copied, the remote PC
used another
program, WinSpool, to send the file to its printer.
When setting up printers in SCO's sysadmsh, you must
specify the device
that the printer is connected to. Since the remote printer
was not
connected to the UNIX machine at all, I specified the
/dev/null
device. The next task was to modify the printer interface
file that
was created for this printer. I did not want the standard
interface
file because the purpose of that file is to redirect
the print file
out to the printer's device. Since I had assigned the
/dev/null
device for this printer, this meant I would never get
any output.
Instead, I wanted to modify the interface file so that
it would use
the rcp command to copy the print file over to the remote
system. Listing 1 is a printout of the interface file
for the remote
printer. Its purpose is to send the print file to a
remote machine
whose name is sales1. sales1's IP address is defined
in the /etc/hosts file.
The method I use for naming the file on the remote machine
might need
further explanation. I give the file on the remote machine
the same
name as the filename in UNIX. However, because of this,
if the user
requests multiple print copies of that one file, I will
have to copy
the file multiple times, once for each copy that is
to be made. Thus,
the file name on the remote machine had to be unique
in order to keep
it from being overwritten in cases where multiple copies
were requested.
The uniqueness is derived by prefixing the file name
with a loop counter.
This way I could still keep the filenames the same on
both machines,
but the remote machine's filename would be prefixed
with the copy
number.
|