Date: Mon, 1 Feb 1999 14:46:45 -0700 From: Tom Poindexter To: andreoli@pisoft.it Subject: new mulinux script: lpr (remote) Hi Michele. Greetings from Denver, Colorado, USA. I have been enjoying muLinux for some time. I have a script to contribute, 'lpr', which unlike the distributed lpr, this one prints via remote print queues. I have tested with the remote print queues on Linux and Solaris. I'm attaching two copies, 'lpr.full' (3736 bytes), and 'lpr.lite' (2654 bytes). lpr.lite has most of the comments and indentation stripped out. Here's how it works: 1. the environment variable PRINTER or the -P option is used to specify the remote printer, as "host:printer". 2. find a reserved tcp port (512 - 1023). Linux lpd requires that clients connect from a reserved port; Solaris lpadmin doesn't care. use nc to scan local ports from 1023 down until it fails. 3. check if 'lpq' or 'lprm' should be run instead by examining $0. send the lpq or lprm request via 'nc' and exit. lpq can take an optional '-l' for a verbose list; lprm usage is 'lprm userid jobnum', as in 'lprm root 39' 4. if no files are specified, stdin is gathered to a temp file. otherwise go through the files to weed out any files that don't exist. 5. generate a 'control file' as a shell variable, which contains the lpd control file of files to print. up to 26 data files can be printed, a sequence letter A-Z is generated for each data file. 6. send the control file followed by all of the data files as input to 'nc'. the normal file handshaking with the remote lpd is ignored. 7. return code information from the remote lpd is ignored. 'lpq' and 'lprm' should be linked to 'lpr'. In order to keep the existing lpr, you may want to rename my 'lpr' to 'lprem', and link 'lpqrem', and 'lprmrem'. Presumably, you would probably want to include PRINTER in the Tcp configuration. The lpd on the remote machine must be configured to allow client lpr. /etc/hosts.equiv and/or /etc/hosts.lpd are the configuration files. My lpr doesn't require any special configuration on the remote system. Again, Linux's BSD-style lpd is more picky about who it allows to connect. Solaris's SysV-style lpadmin may not care, depending on its configuration. You must be running as root to secure a reserved port of course. Or perhaps you would want to make 'nc' suid. One last comment, I'd recommend dropping one of the window managers from the X11 disk in favor some other binaries or additional fonts. AfterStep is my choice to drop; it looks rather clunky with 4-bit colors, and the tool bar takes up too much desktop area. Best regards, and keep up the good work! Tom -- Tom Poindexter tpoindex@nyx.net http://www.nyx.net/~tpoindex/