Книга: Linux Network Administrator Guide, Second Edition
Using nprint with the Line Printer Daemon
Using nprint with the Line Printer Daemon
You will recall we previously mentioned that the -c option for the ncpmount is useful for printing. At last we'll explain why and how.
Linux usually uses BSD-style line printer software. The line printer daemon (lpd) is a daemon that checks a local spool directory for queued jobs that are to be printed. lpd reads the printer name and some other parameters from the specially formatted spool file and writes the data to the printer, optionally passing the data through a filter to transform or manipulate it in some way.
The lpd daemon uses a simple database called /etc/printcap to store printer configuration information, including what filters are to be run. lpd usually runs with the permissions of a special system user called lp.
You could configure nprint as a filter for the lpd to use, which allows users of your Linux machine to output directly to remote printers hosted by a NetWare fileserver. To do this, the lp user must be able to write NCP requests to the NCP connection to the server.
An easy way to achieve this without requiring the lp user to establish its own connection and login is to specify lp as the owner of a connection established by another user. A complete example of how to set up the Linux printing system to handle print jobs from clients over NetWare is listed in three steps:
1. Write a wrapper script.
The /etc/printcap file doesn't permit options to be supplied to filters. Therefore, you need to write a short script that invokes the command you want along with its options. The wrapper script could be as simple as:
#!/bin/sh # p2pslaser - simple script to redirect stdin to the
# PSLASER queue on the REDS01 server
#
/usr/bin/nprint -S REDS01 -U stuart -q PSLASER
#
Store the script in the file /usr/local/bin/p2pslaser.
2. Write the /etc/printcap entry.
We'll need to configure the p2pslaser script we created as the output filter in the /etc/printcap. This would look something like:
pslaser|Postscript Laser Printer hosted by NetWare server:
:lp=/dev/null:
:sd=/var/spool/lpd/pslaser:
:if=/usr/local/bin/p2pslaser:
:af=/var/log/lp-acct:
:lf=/var/log/lp-errs:
:pl#66:
:pw#80:
:pc#150:
:mx#0:
:sh:
3. Add the -c option to the ncpmount.
ncpmount -S REDS01… -c lp…
Our local user stuart must specify the lp user as the owner of the connection when he mounts the remote NetWare server.
Now any Linux user may choose to specify pslaser as the printer name when invoking lp. The print job will be sent to the specified NetWare server and spooled for printing.
- QLineEdit
- 4.4.4 The Dispatcher
- About the author
- Chapter 7. The state machine
- Appendix E. Other resources and links
- Caveats using NAT
- Example NAT machine in theory
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- The final stage of our NAT machine
- Compiling the user-land applications
- The conntrack entries
- Untracked connections and the raw table