Subject: Re: bin/11907: Default /etc/printcap file needs more modern samples
To: NetBSD GNATS submissions and followups <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 01/07/2001 20:22:23
[ On Sunday, January 7, 2001 at 15:07:02 (+0100), anders@dinsen.net wrote: ]
> Subject: bin/11907: Default /etc/printcap file needs more modern samples
>
> Include the following sample entry in the default /etc/printcap:
> 
> ps|PostScript printer:\
>     :lp=/dev/lpa2:sf:sh:mx#0:sd=/var/spool/lpd/lp:lf=/var/log/lpd-errs:

Note that all the example entries in /etc/printcap should also be
converted to use the modern, hier(7) approved, /var/spool/output/ as the
spool directory prefix.  /var/spool/lpd is apparently deprecated, and
the new default for "sd=" is "/var/spool/output/lpd".

Note also that PostScript printers typically can talk back to the host
their attached to (esp. if they are on a serial port, but many support
bi-directional parallel ports too, for example the Apple LaserWriter
16/600PS and Color LW 12/600PS both contain a bi-directional parallel
port that conforms to the IEEE 1284 standard), so as to do things like
report the current printer status, read responses to specific queries
such as finding out the printer's total page count for job accounting,
report errors encountered in PostScript jobs, etc.

To make use of this feature one generally has to have a smart interface
program that knows how to talk to a PostScript printer on behalf of
"lpd".  One such program that can do this is the "postio" program from
AT&T (in V9, SysVr4, and Plan-9) "lprps" by James Clark, available at
<URL:ftp://ftp.jclark.com/pub/lprps/lprps-2.5.tar.Z>.  There's currently
no pkgsrc module for lprps, but there's been one in FreeBSD's ports
system for quite some time so it shouldn't be hard to convert over....
(The "ifhp" filter in LPRng can apparently also do this.)

Note: I've not attempted recently, but in NetBSD-1.3.2 and earlier there
was something broken in LPD that prevented lprps from ever successfully
sending a job to the printer (though it could communicate with the
printer and successfully retrieved the page counts and status, etc.).
IIRC the bug has something to do with LPD apparently not sending the job
to the filter's stdin, or something like that.

Another common PostScript printer issue is how to load fonts into the
printer for those jobs that need them (i.e. any font other than the
usual 35 built-in fonts found in most true PostScript printers).
Unfortunately lprps isn't smart enough to scan the job and pre-load any
fonts it might need.  The printing system included in AT&T UNIX System V
Release 4 had a basic PostScript filter (download) that could do this,
but I've not yet encountered any freeware one.  There is a copy of
download (and postio) in the Plan 9 source, but I don't know if it's
truly freely available.

Note that there is some very minimal support for specifying up to four
font files to any printer queue when printing files with one of `-d',
`-n', or `-t'.  This is an extremely undocumented part of the LPR
system (I have some half-baked fixes to the manual pages), though
basically all it does is write four pathnames to a ".railmag" file in
the spool directory and it is expected that the "df", "nf", or "tf"
filter program will read this file and "Do The Right Thing(tm)".


An example should probably be given for a remote PostScript printer too:

# Typical remote PostScript printer entry.
psrem|Remote PostScript Printer:\
	:rm=remote_machine_hostname:\
	:mx#0:sf:sh:sb:\
	:lf=/var/log/lpd-errs:

And maybe one for a printer on a terminal server:

# Typical PostScript printer connected to a terminal server that listens
# on a TCP port specified below as "port#".
psts|PostScript Printer on Terminal Server:\
	:lp=port#@terminal_server_hostname:\
	:mx#0:sf:sh:sb:\
	:lf=/var/log/lpd-errs:


I don't know how common Apple's TCP/IP LPD implementation is in their
newer printers, but with at least the Apple LaserWriter 16/600PS and the
Color 12/600PS the following entries are useful:

# Entries suitable for an Apple LaserWriter with TCP/IP (eg. 16/600PS)
#
# the remote printer name (rp) specifies how the printer will treat the
# input data.  "raw" is suitable for PostScript or HP PCL-5 output, and
# "text" is suitable for ASCII (an ASCII CR is appended to every line so
# as to avoid the stair-step effect when printing Unix text files)
#
# The printer's Ethernet port should be configured to "AutoSelect" for
# TCP/IP, which is the default on a 16/600PS if the configuration switch
# is in the "down" position.
#
# Unfortunately in this mode the printer cannot report job errors.
#
text|Apple LaserWriter w/TCP-IP as a text printer:\
        :rm=printer-hostname.example.com:\
	:rp=text:\
        :mx#0:sf:sh:sb:\
        :rg=staff:rs:\
        :lf=/var/log/lpd-errs:
#
ps|pcl|Apple LaserWriter w/TCP-IP as a PostScript or PCL-5 printer:\
        :rm=printer-hostname.example.com:\
	:rp=raw:\
        :mx#0:sf:sh:sb:\
        :rg=staff:rs:\
        :lf=/var/log/lpd-errs:

> The following entry would also be useful in combination with the
> script given below (requires installation of the a2ps package) since
> it turns queue lp into an ordinary ASCII printer:

Note that the NetAtalk printer support filter is also called 'psf',
though its actual filter programs have other names.

Note also that the 'enscript' program is also a suitable filter for
converting from text to PostScript, and there's 'pcps', 'mpage', and
even 'mp' too (and all are in pkgsrc).


I find the following comments are also useful to assist non-experts in
configuring their printers:

# To keep the peons from printing you can add a line such as this to any entry:
#	:rg=staff:rs:\
# which says that only users who are members of the group 'staff', and who have
# accounts on the local host, will be allowed to print.
#
# "lpr" defaults to using the printer called "lp" -- add that name as an alias
# for your most commonly used, or default, printer.
#
# Each printer should have a unique spool directory (sd=) of its own, which
# must be created before lpd is restarted.  If you only have one printer you
# can use the existing default spool directory (/var/spool/output/lpd).

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>