home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / DOC / HOWTO / PRINTIN0.GZ / PRINTIN0
Encoding:
Text File  |  1996-08-02  |  35.4 KB  |  896 lines

  1.   The Linux Printing HOWTO
  2.   Grant Taylor, <gtaylor+pht@picante.com>
  3.   v3.9, 25 July 1996
  4.  
  5.   This is the Linux Printing HOWTO, a collection of information on how
  6.   to generate, preview, print and fax anything under Linux (and other
  7.   Unices in general).
  8.  
  9.   1.  Intro
  10.  
  11.   Since this is a complete rewrite, much information from previous
  12.   editions has been lost.  This is by design, as the previous HOWTOs
  13.   were so large as to be 60 typeset pages, and had the narrative flow of
  14.   a dead turtle.  If you do not find the answer here, you are encouraged
  15.   to a) scan the previous version at The PHT Home Page
  16.   <http://www.picante.com/~gtaylor/pht/> and b) drop me a note saying
  17.   what ought to be here but isn't.
  18.  
  19.   The Printing HOWTO Home Page <http://www.picante.com/~gtaylor/pht/> is
  20.   a good place to find the latest version; it is also, of course,
  21.   distributed from SunSite (sunsite.unc.edu) and your friendly local LDP
  22.   mirror.
  23.  
  24.   1.1.  History
  25.  
  26.   This is the third generation, which is to say the third complete
  27.   rewrite, of the Printing HOWTO.  The history of the PHT may be
  28.   chronicled thusly:
  29.  
  30.   1. I wrote the printing-howto in response to too many printing
  31.      questions in comp.os.linux, and posted it.  This predated the HOWTO
  32.      project by a few months and was thus the first FAQlet called a
  33.      `howto'.  This edition was in plain ascii.
  34.  
  35.   2. After joining the HOWTO project, the Printing-HOWTO was merged with
  36.      an Lpd FAQ by Brian McCauley <B.A.McCauley@bham.ac.uk>; we
  37.      continued to co-author the PHT for two years or so.  At some point
  38.      we incorporated the work of Karl Auer <Karl.Auer@anu.edu.au>.  This
  39.      generation of the PHT was in TeXinfo, and available in PS, HTML,
  40.      Ascii, and Info.
  41.  
  42.   3. After letting the PHT rot and decay for over a year, and an
  43.      unsuccessful attempt at getting someone else to maintain it, this
  44.      rewrite happened.  This generation of the PHT is in Linuxdoc-SGML.
  45.  
  46.   1.2.  Copyright
  47.  
  48.   This document is Copyright (c) 1996 by Grant Taylor.  Please copy and
  49.   distribute it widely, but do not modify the text or omit my name.
  50.  
  51.   2.  How to print
  52.  
  53.   If you've already got lpd setup to print to your printer, or your
  54.   system administrator already did so, or your vendor did so for you,
  55.   then all you need to do is learn how to use the lpr command.  The
  56.   Printing Usage HOWTO <http://sunsite.unc.edu/mdw/HOWTO/Printing-Usage-
  57.   HOWTO.html> covers this, and a few other queue manipulation commands
  58.   you should probably know.
  59.  
  60.   3.  Kernel printer devices
  61.  
  62.   3.1.  The lp device
  63.  
  64.   The Linux kernel, assuming you have compiled in or loaded the lp
  65.   device (the output of cat /proc/devices should include the device lp),
  66.   provides one or more of /dev/lp0, /dev/lp1, and /dev/lp2.  These are
  67.   NOT assigned dynamically, rather, each corresponds to a specific
  68.   hardware I/O address.  This means that your first printer may be lp0
  69.   or lp1 depending on your hardware.  Try both ;)
  70.  
  71.   One cannot run the plip and lp drivers at the same time on any given
  72.   port.  You can, however, have one or the other driver loaded at any
  73.   given time either manually, or by kerneld with v2 (and later 1.3.x)
  74.   kernels.  By carefully setting the interrupts and such, you can
  75.   supposedly run plip on one port and lp on the other.  One person did
  76.   so by editing the drivers; I eagerly await a success report of someone
  77.   doing so with only a clever command line.
  78.  
  79.   There is a little utility called tunelp floating about with which you,
  80.   as root, can tune the Linux lp device's interrupt usage, polling rate,
  81.   and other options.
  82.  
  83.   When built in to some 1.3.x and v2 kernels, the kernel will accept an
  84.   lp= option to set interrupts and io addresses:
  85.  
  86.        When the lp driver is built in to the kernel, you may use the
  87.        LILO/LOADLIN command line to set the port addresses and interrupts
  88.        that the driver will use.
  89.  
  90.        Syntax:      lp=port0[,irq0[,port1[,irq1[,port2[,irq2]]]]]
  91.  
  92.        For example:   lp=0x378,0   or   lp=0x278,5,0x378,7 **
  93.  
  94.        Note that if this feature is used, you must specify *all* the ports
  95.        you want considered, there are no defaults.  You can disable a
  96.        built-in driver with lp=0.
  97.  
  98.   When loaded as a module in version 2 and late-model 1.3.x kernels, it
  99.   is possible to specify io addresses and interrupt lines on the insmod
  100.   command line (or in /etc/conf.modules so as to affect kerneld) using
  101.   the usual syntax.  The parameters are io=port0,port1,port2 and
  102.   irq=irq0,irq1,irq2.  Read ye the man page for insmod for more
  103.   information on this.
  104.  
  105.   **For those of you who (like me) can never find the standard port
  106.   numbers when you need them, they are as in the second example above.
  107.   The other port (lp0) is at 0x3bc.  I've no idea what interrupt it
  108.   usually uses.
  109.  
  110.   3.2.  Serial devices
  111.  
  112.   Serial devices are usually called something like /dev/ttyS1 under
  113.   Linux.  The utility stty will allow you to interactively view or set
  114.   the settings for a serial port; setserial will allow you to control a
  115.   few extended attributes and configure IRQs and I/O addresses for non-
  116.   standard ports.  Further discussion of serial ports under Linux may be
  117.   found in the Serial-HOWTO <http://sunsite.unc.edu/mdw/HOWTO/Serial-
  118.   HOWTO.html>.
  119.  
  120.   4.  How it works, basic
  121.  
  122.   In order to get printing working well, you need to understand how the
  123.   lpd system works.
  124.  
  125.   Lpd stands for Line Printer Daemon, and refers in different contexts
  126.   to both the daemon and the whole collection of programs which run
  127.   print spooling.  These are:
  128.  
  129.      lpd
  130.         The spooling daemon.  One of these runs to control everything on
  131.         a machine, AND one is run per printer while the printer is
  132.         printing.
  133.  
  134.      lpr
  135.         The user spooling command.  Lpr contacts lpd and injects a new
  136.         print job into the spool.
  137.  
  138.      lpq
  139.         Lists the jobs in a print queue.
  140.  
  141.      lpc
  142.         The Lpd system control command.  With lpc you can stop, start,
  143.         reorder, etc, the print queues.
  144.  
  145.      lprm
  146.         lprm will remove a job from the print spool.
  147.  
  148.   So how does it fit together?  Well, when the system boots, lpd is run.
  149.   It scans the file /etc/printcap to learn which printers it will be
  150.   managing spools for.  Each time someone runs lpr, lpr contacts lpd
  151.   through the named socket /dev/printer, and feeds lpd both the file to
  152.   print and some information about who is printing and how to print it.
  153.   Lpd then prints the file on the appropriate printer in turn.
  154.  
  155.   The lp system was originally designed when most printers were line
  156.   printers - that is, people mostly printed plain ascii.  As it turns
  157.   out, only a little extra scripting is needed to make lpd work quite
  158.   well for today's print jobs, which are often in PostScript, or text,
  159.   or dvi, or...
  160.  
  161.   5.  How to set things up, basic
  162.  
  163.   5.1.  Traditional lpd configuration
  164.  
  165.   The minimal setup for lpd rsults in a system that can queue files and
  166.   print them.  It will not pay any attention to wether or not your
  167.   printer will understand them, and will probably not let you produce
  168.   attractive output.  Nevertheless, it is the first step to
  169.   understanding, so read on!
  170.  
  171.   Basically, to add a print queue to lpd, you must add an entry in
  172.   /etc/printcap, and make the new spool directory under /var/spool/lpd.
  173.  
  174.   An entry in /etc/printcap looks like:
  175.  
  176.   # LOCAL djet500
  177.   lp|dj|deskjet:\
  178.           :sd=/var/spool/lpd/dj:\
  179.           :mx#0:\
  180.           :lp=/dev/lp0:\
  181.           :sh:
  182.  
  183.   This defines a spool called lp, dj, or deskjet, spooled in the direc¡
  184.   tory /var/spool/lpd/dj, with no per-job maximum size limit, which
  185.   prints to the device /dev/lp0, and which does not have a banner page
  186.   (with the name of the person who printed, etc) added to the front of
  187.   the print job.
  188.  
  189.   Go now and read the man page for printcap.
  190.  
  191.   The above looks very simple, but there a catch - unless I send in
  192.   files a DeskJet 500 can understand, this DeskJet will print strange
  193.   things.  For example, sending an ordinary Unix text file to a deskjet
  194.   results in literally interpreted newlines, and gets me:
  195.  
  196.        This is line one.
  197.                         This is line two.
  198.                                          This is line three.
  199.  
  200.   ad nauseum.  Printing a PostScript file to this spool would get a
  201.   beautiful listing of the PostScript commands, printed out with this
  202.   "staircase effect", but no useful output.
  203.  
  204.   Clearly more is needed, and this is the purpose of filtering.  The
  205.   more observant of you who read the printcap man page might have
  206.   noticed the spool attributes if and of.  Well, if, or the input
  207.   filter, is just what we need here.
  208.  
  209.   If we write a small shell script called filter that adds carriage
  210.   returns before newlines, the staircasing can be eliminated.  So we
  211.   have to add in an if line to our printcap entry above:
  212.  
  213.        lp|dj|deskjet:\
  214.                :sd=/var/spool/lpd/dj:\
  215.                :mx#0:\
  216.                :lp=/dev/lp0:\
  217.                :if=/var/spool/lpd/dj/filter:\
  218.                :sh:
  219.  
  220.   A simple filter script might be:
  221.  
  222.        #!perl
  223.        while(<STDIN>){chop $_; print "$_\r\n";};
  224.  
  225.   If we were to do the above, we'd have a spool to which we could print
  226.   regular Unix text files and get meaningful results.  (Yes, there are
  227.   four million better ways to write this filter, but few so illustra¡
  228.   tive.  You are encouraged to do this more efficiently.)
  229.  
  230.   The only remaining problem is that printing plain text is really not
  231.   too hot - surely it would be better to be able to print PostScript and
  232.   other formatted or graphic types of output.  Well, yes, it would, and
  233.   it's easy to do.  The method is simply an extention of the above
  234.   linefeed-fixing filter.  If you write a filter than can accept
  235.   arbitrary file types as input and produce DeskJet-kosher output for
  236.   each case, then you've got a clever print spooler indeed!
  237.  
  238.   Such a filter is called a magic filter.  Don't bother writing one
  239.   yourself unless you print strange things - there are a good many
  240.   written for you already on the net.
  241.  
  242.   5.2.  File Permissions
  243.  
  244.   By popular demand, I include below a listing of the permissions on
  245.   interesting files on my system.  There are a number of better ways to
  246.   do this, ideally using only SGID binaries and not making everything
  247.   SUID root, but this is how my system came out of the box, and it works
  248.   for me.  (Quite frankly, if your vendor can't even ship a working lpd
  249.   you're in for a rough ride).
  250.  
  251.        -r-sr-sr-x   1 root     lp    /usr/bin/lpr*
  252.        -r-sr-sr-x   1 root     lp    /usr/bin/lprm*
  253.        -rwxr--r--   1 root     root  /usr/sbin/lpd*
  254.        -r-xr-sr-x   1 root     lp    /usr/sbin/lpc*
  255.        drwxrwxr-x   4 root     lp    /var/spool/lpd/
  256.        drwxr-xr-x   2 root     lp    /var/spool/lpd/lp/
  257.  
  258.   Lpd must currently be run as root so that it can bind to the low-
  259.   numbered lp service port.  It should probably become UID lp.lp or
  260.   something after binding, but I don't think it does.  Bummer.
  261.  
  262.   6.  How to obtain an appropriate magic filter
  263.  
  264.   6.1.  APS Filter
  265.  
  266.   One of the nicest magic filter packages is aps filter, by Andreas
  267.   Klemm.  The Linux Software Map entry goes something like this:
  268.  
  269.   Begin3
  270.   Title:          apsfilter
  271.   Version:        4.9.1
  272.   Entered-date:   Montag, 10. Juli 1995, 21:22:35 Uhr MET DST
  273.   Description:    magicfilter for lpd with auto filetype detection
  274.   Keywords:       lpd magicfilter aps apsfilter
  275.   Author:         andreas@knobel.GUN.de (Andreas Klemm)
  276.   Maintained-by:  sledge@hammer.oche.de (Thomas Bueschgens)
  277.                   andreas@knobel.GUN.de (Andreas Klemm)
  278.   Primary-site:   sunsite.unc.edu
  279.                   /pub/Linux/system/Printing/
  280.                   211KB aps-491.tgz
  281.   Original-site:  ftp-i2.informatik.rwth-aachen.de
  282.                   /pub/Linux/pak/APSfilter/aps-491.tgz
  283.   Platforms:      C-Compiler, gs Postscript emulator, pbmutils
  284.   Copying-policy: GPL
  285.   End
  286.  
  287.   APS filter installs as an if filter for a print queue, and will trans¡
  288.   late from many common file types into your printer's command set.  It
  289.   understands, for example, text, PostScript, dvi, gif, and others.
  290.  
  291.   6.2.  Magic-filter
  292.  
  293.   The magic-filter package, written by B.A.McCawley, works much the same
  294.   way as does APSfilter, but since it is written in bash, it might be
  295.   more easy to customize.  The LSM entry:
  296.  
  297.        Version: 0.4
  298.        Description: Bash scripts to simplify the task of configuring lpd to
  299.           auto-detect file types using /etc/magic. (As advertised in the
  300.           printing-HOWTO).
  301.           This package uses existing filters so it only prints file types for
  302.           which one already has filters (or compressed versions
  303.           thereof). Alterative magic filter approches are described in the
  304.           printing-HOWTO.
  305.        Keywords: lpd, /etc/magic, printing, filter
  306.        Author: B.A.McCauley@bham.ac.uk (Brian McCauley)
  307.        Maintained-by: B.A.McCauley@bham.ac.uk
  308.        Primary-site: tsx-11.mit.edu pub/linux/sources/usr.bin
  309.                      magic-filter-0.4.tar.gz  5709
  310.        Copying-policy: GNU GPL
  311.  
  312.   6.3.  The other Magicfilter
  313.  
  314.   For maximum confusion, there appear to be two packages named just
  315.   magic filter out there.  (Or are they the same?)
  316.  
  317.   Title:          magicfilter
  318.   Version:        1.1b
  319.   Entered-date:   04APR95
  320.   Description:    A customizable, extensible automatic printer filter.
  321.                   Lets you automatically detect and print just about any
  322.                   data type you can find a conversion utility for.  This
  323.                   filter is written in C and is controlled completely
  324.                   from an external printer configuration file.
  325.                   This version adds automagic creation of configuration
  326.                   files based on the installed software on your system,
  327.                   courtesy of GNU Autoconf.
  328.                   This version is a bug fix from 1.1/1.1a; filters for
  329.                   non-ASCII capable PostScript printers have been added.
  330.   Author:         H. Peter Anvin <Peter.Anvin@linux.org>
  331.   Primary-site:   sunsite.unc.edu
  332.                   53000 /pub/Linux/system/Printing/magicfilter-1.1b.tar.gz
  333.   Copying-policy: GPL
  334.  
  335.   7.  Serial printers under lpd
  336.  
  337.   7.1.  Setting up in printcap
  338.  
  339.   Lpd provides five attributes which you can set in /etc/printcap to
  340.   control all the settings of the serial port a printer is on.  Read the
  341.   printcap man page and note the meanings of br#, fc#, xc#, fs# and xs#.
  342.   The last four of these attributes are bitmaps indicating the settings
  343.   for use the port.  The br# atrribute is simply the baud rate, ie
  344.   `br#9600'.
  345.  
  346.   It is very easy to translate from stty settings to printcap flag
  347.   settings. If you need to, see the man page for stty now.
  348.  
  349.   Use stty to set up the printer port so that you can cat a file to it
  350.   and have it print correctly. Here's what `stty -a' looks like for my
  351.   printer port:
  352.  
  353.        dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2
  354.        speed 9600 baud; rows 0; columns 0; line = 0;
  355.        intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  356.        eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
  357.        lnext = ^V; min = 1; time = 0;
  358.        -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
  359.        -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr
  360.        -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel
  361.        -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0
  362.        bs0 vt0 ff0
  363.        -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase
  364.        -tostop -echoprt -echoctl -echoke
  365.  
  366.   The only changes between this and the way the port is initialized at
  367.   bootup are -clocal, -crtscts, and ixon. Your port may well be differ¡
  368.   ent depending on how your printer does flow control.
  369.  
  370.   You actually use stty in a somewhat odd way.  Since stty operates on
  371.   the terminal connected to it's standard input, you use it to
  372.   manipulate a given serial port by using the `<' character as above.
  373.  
  374.   Once you have your stty settings right, so that `cat file >
  375.   /dev/ttyS2' (in my case) sends the file to the printer, look at the
  376.   file /usr/src/linux/include/linux/termios.h. This contains a lot of
  377.   #defines and a few structs (You may wish to cat this file to the
  378.   printer (you do have that working, right?) and use it as scratch
  379.   paper).  Go to the section that starts out
  380.  
  381.        /* c_cflag bit meaning */
  382.        #define CBAUD   0000017
  383.  
  384.   This section lists the meaning of the fc# and fs# bits. You will
  385.   notice that the names there (after the baud rates) match up with one
  386.   of the lines of stty output. Didn't I say this was going to be easy?
  387.  
  388.   Note which of those settings are preceded with a - in your stty
  389.   output. Sum up all those numbers (they are octal). This represents the
  390.   bits you want to clear, so the result is your fc# capability.  Of
  391.   course, remember that you will be setting bits directly after you
  392.   clear, so you can just use `fc#0177777' (I do).
  393.  
  394.   Now do the same for those settings (listed in this section) which do
  395.   not have a - before them in your stty output. In my example the
  396.   important ones are CS8 (0000060), HUPCL (0002000), and CREAD
  397.   (0000200). Also note the flags for your baud rate (mine is 0000015).
  398.   Add those all up, and in my example you get 0002275. This goes in your
  399.   fs# capability (`fs#02275' works fine in my example).
  400.  
  401.   Do the same with set and clear for the next section of the include
  402.   file, "c_lflag bits". In my case I didn't have to set anything, so I
  403.   just use `xc#0157777' and `xs#0'.
  404.  
  405.   7.2.  Older serial printers that drop characters
  406.  
  407.   Jon Luckey points out that some older serial printers with ten-cent
  408.   serial interfaces and small buffers really mean stop when they say so
  409.   with flow control.  He found that disabling the FIFO in his Linux
  410.   box's 16550 serial port with setserial corrected the problem of
  411.   dropped characters (you apparently just specify the uart type as an
  412.   8250 to do this).
  413.  
  414.   8.  Vendor Solutions
  415.  
  416.   This section is, by definition, incomplete.  Feel free to send in
  417.   details of your favourite distribution.
  418.  
  419.   8.1.  RedHat 2.x
  420.  
  421.   RedHat has a GUI printer administration tool which can add remote
  422.   printers and printers on local devices.  It lets you choose a
  423.   ghostscript-supported printer type and Unix device file to print to,
  424.   then installs a print queue in /etc/printcap and writes a short
  425.   PostScript-and-ascii magic filter based around gs and nenscript.  This
  426.   solution works fairly well, and is trivial to setup for common cases.
  427.  
  428.   8.2.  Other Distributions
  429.  
  430.   Please send me info on what other distributions do.
  431.  
  432.   9.  How to print to a printer over the network
  433.  
  434.   One of the features of lpd is that it supports printing over the
  435.   network to printers physically connected to a different machine.  With
  436.   the careful combination of filter scripts and assorted utilities, you
  437.   can make lpr print transparently to printers on all sorts of networks.
  438.  
  439.   9.1.  To a Unix/lpd host
  440.  
  441.   To allow remote machines to print to your printer, you must list the
  442.   machines in /etc/hosts.equiv or /etc/hosts.lpd.  (Note that
  443.   hosts.equiv has a host of other effects; be sure you know what you are
  444.   doing if you list any machine there).  You can allow only certain
  445.   users on the other machines to print to your printer by usign the rs
  446.   attribute; read the lpd man page for information on this.
  447.  
  448.   9.2.  With lpd
  449.  
  450.   To print to another machine, you make an /etc/printcap entry like
  451.   this:
  452.  
  453.        # REMOTE djet500
  454.        lp|dj|deskjet:\
  455.                :sd=/var/spool/lpd/dj:\
  456.                :rm=machine.out.there.com:\
  457.                :rp=printername:\
  458.                :lp=/dev/null:\
  459.                :sh:
  460.  
  461.   Note that there is still a spool directory on the local machine man¡
  462.   aged by lpd.  If the remote machine is busy or offline, print jobs
  463.   from the local machine wait in the spool area until they can be sent.
  464.  
  465.   9.3.  With rlpr
  466.  
  467.   You can also use rlpr to send a print job directly to a queue on a
  468.   remote machine without going through the hassle of configuring lpd to
  469.   handle it.  This is mostly useful in situations where you print to a
  470.   variety of printers only occasionally.  From the announcement for
  471.   rlpr:
  472.  
  473.   Rlpr uses TCP/IP to send print jobs to lpd servers anywhere on a
  474.   network.
  475.  
  476.   Unlike lpr, it *does not* require that the remote printers be
  477.   explicitly known to the machine you wish to print from, (e.g. through
  478.   /etc/printcap) and thus is considerably more flexible and requires
  479.   less administration.
  480.  
  481.   rlpr can be used anywhere a traditional lpr might be used, and is
  482.   backwards compatible with traditional BSD lpr.
  483.  
  484.   The main power gained by rlpr is the power to print remotely *from
  485.   anywhere to anywhere* without regard for how the system you wish to
  486.   print from was configured.  Can work as a filter just like traditional
  487.   lpr so that clients executing on a remote machine like netscape,
  488.   xemacs, etc, etc can print to your local machine with little effort.
  489.  
  490.   Rlpr is available from SunSite
  491.   <ftp://sunsite.unc.edu/pub/Linux/system/Printing/>.
  492.  
  493.   9.4.  To a Win95, WinNT, LanManager, or Samba printer
  494.  
  495.   It is possible to direct an lpd queue through the smbclient program
  496.   (part of the samba suite) to a TCP/IP based SMB print service.  Samba
  497.   includes a script to do this called smbprint.  In short, you put a
  498.   configuration file for the specific printer in question in the spool
  499.   directory, and install the smbprint script as the if.
  500.  
  501.   The /etc/printcap entry goes like this:
  502.  
  503.        lp|remote-smbprinter:\
  504.            :lp=/dev/null:sh:\
  505.            :sd=/var/spool/lpd/lp:\
  506.            :if=/usr/local/sbin/smbprint:
  507.  
  508.   You should read the documentation inside the smbprint script for more
  509.   information on how to set this up.
  510.  
  511.   You can also use smbclient to submit a file directly to an SMB
  512.   printing service without involving lpd.  See the man page.
  513.  
  514.   9.5.  To a NetWare Printer
  515.  
  516.   The ncpfs suite includes a utility called nprint which provides the
  517.   same functionality as smbprint but for NetWare.  You can get ncpfs
  518.   from  <ftp://linux01.gwdg.de/pub/ncpfs/>.  From the LSM entry for
  519.   version 0.16:
  520.  
  521.        With ncpfs you can mount volumes of your netware server
  522.        under Linux. You can also print to netware print queues and
  523.        spool netware print queues to the Linux printing system. You
  524.        need kernel 1.2.x or 1.3.54 and above. ncpfs does NOT work
  525.        with any 1.3.x kernel below 1.3.54.
  526.  
  527.   To make nprint work via lpd, you write a little shell script to print
  528.   stdin on the NetWare printer, and install that as the if for an lpd
  529.   print queue.  You'll get something like:
  530.  
  531.   sub2|remote-NWprinter:\
  532.           :lp=/dev/null:sh:\
  533.           :sd=/var/spool/lpd/sub2:\
  534.           :if=/var/spool/lpd/nprint-script:
  535.  
  536.   The nprint-script might look approximately like:
  537.  
  538.        #! /bin/sh
  539.        /usr/local/bin/nprint -S net -U name -P passwd -q printq-q -
  540.  
  541.   9.6.  To an EtherTalk (Apple) printer
  542.  
  543.   The netatalk package includes something like nprint and smbclient.
  544.   Werner Eugster has documented the procedure for printing to and from
  545.   an Apple network far better than I ever will; see his web page
  546.   <http://garnet.berkeley.edu/~weugster/appleprint.html>.
  547.  
  548.   Obscure caveat of the week: Netatalk does not work with SMC Etherpower
  549.   PCI Card with a DEC tulip chip.
  550.  
  551.   9.7.  To an HP or other ethernet printer
  552.  
  553.   HPs and some other printers come with an ethernet interface which you
  554.   can print to directly using lpd.  You should follow the instructions
  555.   that came with your printer or its network adaptor, but in general,
  556.   such printers are "running" lpd, and provide one or more queues which
  557.   you can print to.  An HP, for example, might work with a printcap
  558.   like:
  559.  
  560.        lj-5|remote-hplj:\
  561.                :lp=/dev/null:sh:\
  562.                :sd=/var/spool/lpd/lj-5:\
  563.                :rm=printer.name.com:rp=raw:
  564.  
  565.   In a large scale environment, especially a large environment where
  566.   some printers do not support PostScript, it may be useful to establish
  567.   a dedicated print server to which all machines print and on which all
  568.   ghostscript jobs are run.
  569.  
  570.   9.7.1.  To older HPs
  571.  
  572.   Some printers (and printer networking "black boxes") support only a
  573.   cheesy little non-protocol involving plain TCP connections.  Notable
  574.   in this category are early-model JetDirect (including some
  575.   JetDirectEx) cards.  Basically, to print to the printer, you must open
  576.   a TCP connection to the printer on a specified port (typically 9100)
  577.   and stuff your print job into it.  This can be implemented, among
  578.   other ways, in Perl:
  579.  
  580.   #!/usr/bin/perl
  581.   # Thanks to Dan McLaughlin for writing the original version of this
  582.   # script (And to Jim W. Jones for sitting next to Dan when writing me
  583.   # for help ;)
  584.  
  585.   $fileName = @ARGV[0];
  586.  
  587.   open(IN,"$fileName") || die "Can't open file $fileName";
  588.  
  589.   $dpi300     = "\x1B*t300R";
  590.   $dosCr      = "\x1B&k3G";
  591.   $ends = "\x0A";
  592.  
  593.   $port =  9100 unless $port;
  594.   $them = "bach.sr.hp.com" unless $them;
  595.  
  596.   $AF_INET = 2;
  597.   $SOCK_STREAM = 1;
  598.   $SIG{'INT'} = 'dokill';
  599.   $sockaddr = 'S n a4 x8';
  600.  
  601.   chop($hostname = `hostname`);
  602.   ($name,$aliases,$proto) = getprotobyname('tcp');
  603.   ($name,$aliases,$port) = getservbyname($port,'tcp')
  604.       unless $port =~ /^\d+$/;;
  605.   ($name,$aliases,$type,$len,$thisaddr) =
  606.           gethostbyname($hostname);
  607.   ($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
  608.   $this = pack($sockaddr, $AF_INET, 0, $thisaddr);
  609.   $that = pack($sockaddr, $AF_INET, $port, $thataddr);
  610.  
  611.   if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {
  612.   #    print "socket ok\n";
  613.   }
  614.   else {
  615.       die $!;
  616.   }
  617.   # Give the socket an address.
  618.   if (bind(S, $this)) {
  619.   #    print "bind ok\n";
  620.   }
  621.   else {
  622.       die $!;
  623.   }
  624.  
  625.   # Call up the server.
  626.  
  627.   if (connect(S,$that)) {
  628.   #    print "connect ok\n";
  629.   }
  630.   else {
  631.       die $!;
  632.   }
  633.  
  634.   # Set socket to be command buffered.
  635.  
  636.   select(S); $| = 1; select(STDOUT);
  637.  
  638.   #    print S "@PJL ECHO Hi $hostname! $ends";
  639.   #    print S "@PJL OPMSG DISPLAY=\"Job $whoami\" $ends";
  640.   #    print S $dpi300;
  641.  
  642.   # Avoid deadlock by forking.
  643.  
  644.   if($child = fork) {
  645.       print S $dosCr;
  646.       print S $TimesNewR;
  647.  
  648.       while (<IN>) {
  649.           print S;
  650.       }
  651.       sleep 3;
  652.       do dokill();
  653.   } else {
  654.       while(<S>) {
  655.           print;
  656.       }
  657.   }
  658.  
  659.   sub dokill {
  660.       kill 9,$child if $child;
  661.   }
  662.  
  663.   9.8.  Running an if for remote printers
  664.  
  665.   One oddity of lpd is that the if is not run for remote printers.  If
  666.   you find that you need to run an if, you can do so by setting up a
  667.   double queue and requeueing the job.  As an example, consider this
  668.   printcap:
  669.  
  670.        lj-5:remote-hplj:\
  671.                :lp=/dev/null:sh:\
  672.                :sd=/var/spool/lpd/lj-5:\
  673.                :if=/usr/lib/lpd/filter-lj-5:
  674.        lj-5-remote:lp=/dev/null:sh:rm=printer.name.com:\
  675.                :rp=raw:sd=/var/spool/lpd/lj-5-raw:
  676.  
  677.   in light of this filter-lj-5 script:
  678.  
  679.        #!/bin/sh
  680.        gs <options> -q -dSAFER -sOutputFile=- - | \
  681.                lpr -Plj-5-remote -U$5
  682.  
  683.   The -U option to lpr only works if lpr is run as daemon, and it sets
  684.   the submitter's name for the job in the resubmitted queue correctly.
  685.   You should probably use a more robust method of getting the username,
  686.   since in some cases it is not argument 5.  See the man page for
  687.   printcap.
  688.  
  689.   10.  How to print to a fax machine.
  690.  
  691.   10.1.  Using a faxmodem
  692.  
  693.   There are a number of fax programs out there that will let you fax and
  694.   receive documents.  One of the most complex is Sam Leffler's HylaFax,
  695.   available from ftp.sgi.com.  It supports all sorts of things from
  696.   multiple modems to broadcasting.
  697.  
  698.   Also available, and a better choice for most Linux boxen, is efax, a
  699.   simple program which sends faxes.  The getty program mgetty can
  700.   receive faxes (and even do voicemail on some modems!).
  701.  
  702.   10.2.  Using the Remote Printing Service
  703.  
  704.   There is an experimental service offered that lets you send an email
  705.   message containing something you'd like printed such that it will
  706.   appear on a fax machine elsewhere.  Nice formats like postscript are
  707.   supported, so even though global coverage is spotty, this can still be
  708.   a very useful service.  For more information on printing via the
  709.   remote printing service, see the FAQ
  710.   <http://www.town.hall.org/fax/faq.html>.
  711.  
  712.   11.  How to generate something worth printing.
  713.  
  714.   Here we get into a real rat's-nest of software.  Basically, Linux can
  715.   run four types of binaries with varying degrees of success: Linux,
  716.   iBCS, Win16/Win32s (with dosemu and, someday, with Wine), and Mac/68k
  717.   (with Executor).  I'll just discuss native Linux and common Unix
  718.   software, except to say that WordPerfect for SCO, and quite probably
  719.   other commercial word processing software, runs fine under Linux's
  720.   iBCS emulation.
  721.  
  722.   For Linux itself, choices are mostly limited to those available for
  723.   Unix in general:
  724.  
  725.   11.1.  Markup languages
  726.  
  727.   Most markup languages are more suitable for large or repetative
  728.   projects, where you want the computer to control the layout of the
  729.   text to make things uniform.  Trying to make a pretty sign in a markup
  730.   language would probably hurt...
  731.  
  732.      nroff
  733.         This was one of the first Unix markup languages.  Man pages are
  734.         the most common examples of things formatted in *roff macros;
  735.         many people swear by them, but nroff has, to me at least, a more
  736.         arcane syntax than needed, and probably makes a poor choice for
  737.         new works.  It is worth knowing, though, that you can typeset a
  738.         man page directly into postscript with groff.  Most man commands
  739.         will do this for you with man -t foo | lpr.
  740.  
  741.      TeX
  742.         TeX, and the macro package LaTeX, are one of the most widely
  743.         used markup languages on Unix.  Technical works are frequently
  744.         written in LaTeX because it greatly simplifies the layout issues
  745.         and is still one of the few text processing systems to support
  746.         mathematics both completely and well.  TeX's output format is
  747.         dvi, and is converted to PostScript or Hewlett Packard's PCL
  748.         with dvips or dvilj.
  749.  
  750.      SGML
  751.         There is at least one free sgml parser available for Unix and
  752.         Linux; it forms the basis of Linuxdoc-SGML's homegrown document
  753.         system.  It can support other DTD's, as well.
  754.  
  755.      HTML
  756.         Someone suggested that for simple projects, it may suffice to
  757.         write it in HTML and print it out using Netscape.  I disagree,
  758.         but YMMV.
  759.  
  760.   11.2.  WYSIWYG
  761.  
  762.   There is a general shortage of WYSIWYG text processing software.  Feel
  763.   free to write some, and do let me know of anything I've omitted here.
  764.  
  765.      Lyrix
  766.         Lyrix is a front-end to LaTeX which looks very promising.
  767.  
  768.      The Andrew User Interface System
  769.         AUIS includes ez, a WYSIWYG-style editor with most basic word
  770.         processor features, HTML capabilities, and full MIME email and
  771.         newsgroup support.
  772.  
  773.      Commercial offerings
  774.         At least Caldera and Red Hat ship packages containing the usual
  775.         office apps like a WYSIWYGish word processor and a spreadsheet.
  776.         I would assume they do a dandy job, but I've never used them.  I
  777.         think Caldera also ships Sun's WABI, so you could probably run
  778.         something like MS Office under that if you had to integrate with
  779.         other folks' files.
  780.  
  781.         Jeff Phillips <jeff@I_RATUS.org> uses Caldera's WordPerfect for
  782.         Linux (on Slackware, of all things) and says that it works well.
  783.         It apparently includes built-in printer support, as one would
  784.         expect.  Caldera should have info on  <http://www.caldera.com/>.
  785.  
  786.         RedHat ships a suite called Applixware; you can find their web
  787.         site at  <http://www.redhat.com/>.
  788.  
  789.         Other vendors feel free to drop me a line with your offerings.
  790.  
  791.   12.  Ghostscript.
  792.  
  793.   Ghostscript is an incredibly significant program for Linux printing.
  794.   Most printing software under Unix generates PostScript, which is
  795.   typically a $100-300 option on a printer.  Ghostscript, however, is
  796.   free, and will generate the language of your printer from PostScript.
  797.   When tied in with your lpd input filter, it gives you a virtual
  798.   PostScript printer and simplifies life immensely.
  799.  
  800.   Ghostscript is available in two forms.  The commercial version of
  801.   Ghostscript, called Aladdin Ghostscript, may be used freely for
  802.   personal use but may not be distributed by commercial Linux
  803.   distributions.  It is generally a year or so ahead of the free
  804.   Ghostscript; at the moment, for example, it supports Adobe Acrobat's
  805.   Portable Document Format, while the older Ghostscripts do not.
  806.  
  807.   The free version of Ghostscript is GNU Ghostscript, and is simply an
  808.   aged version of Aladdin ghostscript kindly given to GNU.  (Kudos to
  809.   Aladdin for this arrangement; more software vendors should support
  810.   free software in this way).
  811.  
  812.   Ghostscript's main failing is in its fonts, which are derived from
  813.   bitmap scans of the characters.  Superior, but commercially licensed
  814.   fonts may be obtained from several places, since Ghostscript can read
  815.   type 1 Adobe fonts.  Adobe distributes useable fonts with their
  816.   Acrobat PDF reader, or you may use the fonts from Adobe's ATM or a
  817.   fontpack.
  818.  
  819.   Whatever you do with gs, be very sure to run it with the option for
  820.   disabling file access (-dSAFER).  PostScript is a fully functional
  821.   language, and a bad PostScript program could give you quite a
  822.   headache.
  823.  
  824.   12.1.  Ghostscript output tuning
  825.  
  826.   There are a number of things one can do if gs's output is not
  827.   satisfactory (actually, you can do anything you darn well please,
  828.   since you have the source).
  829.  
  830.   12.1.1.  Output location and size
  831.  
  832.   The location, size, and aspect ratio of the image on a page is
  833.   controlled by the printer-specific driver in ghostscript.  If you find
  834.   that your pages are coming out scrunched too short, or too long, or
  835.   too big by a factor of two, you might want to look in your driver's
  836.   source module and adjust whatever parameters jump out at you.
  837.   Unfortunately, each driver is different, so I can't really tell you
  838.   what to adjust, but most of them are reasonably well commented.
  839.  
  840.   12.1.2.  Gamma, dotsizes, etc.
  841.  
  842.   Most non-laser printers suffer from the fact that their dots are
  843.   rather large. This results in pictures coming out too dark. If you
  844.   experience this problem you should use your own transfer function.
  845.   Simply create the following file in the ghostscript lib-dir and add
  846.   its name to the gs call just before the actual file. You may need to
  847.   tweak the actual values to fit your printer. Lower values result in a
  848.   brighter print.  Especially if your driver uses a Floyd-Steinberg
  849.   algorithm to rasterize colors, lower values ( 0.2 - 0.15 ) are
  850.   probably a good choice.
  851.  
  852.        ---8<---- gamma.ps ----8<---
  853.        %!
  854.        %transfer functions for cyan magenta yellow black
  855.        {0.3 exp} {0.3 exp} {0.3 exp} {0.3 exp} setcolortransfer
  856.        ---8<------------------8<---
  857.  
  858.   It is also possible to mend printers that have some kind of colour
  859.   fault by tweaking these values. If you do that kind of thing, I
  860.   recommend using the file colorcir.ps, that comes with ghostscript (in
  861.   the examples/ subdir), as a test page.
  862.  
  863.   13.  On-screen previewing of printable things.
  864.  
  865.   Nearly anything you can print can be viewed on the screen, too.
  866.  
  867.   13.1.  PostScript
  868.  
  869.   Ghostscript has an X11 driver best used under the management of the
  870.   PostScript previewer Ghostview.  The latest versions of these programs
  871.   should be able to view PDF files, as well.
  872.  
  873.   13.2.  TeX dvi
  874.  
  875.   TeX DeVice Independant files may be previewed under X11 with xdvi.
  876.   Modern versions of xdvi call ghostscript to render PostScript
  877.   specials.
  878.  
  879.   A VT100 driver exists as well.  It's called dgvt.  Tmview works with
  880.   Linux and svgalib, if that's all you can do.
  881.  
  882.   14.  Credits
  883.  
  884.   The smbprint information is from an article by Marcel Roelofs
  885.   <marcel@paragon.nl>.
  886.  
  887.   The nprint information for using Netware printers was provided by
  888.   Michael Smith <mikes@bioch.ox.ac.uk>.
  889.  
  890.   The serial printers under lpd section is from Andrew Tefft
  891.   <teffta@engr.dnet.ge.com>.
  892.  
  893.   The blurb about gammas and such for gs was sent in by Andreas
  894.   <quasi@hub-fue.franken.de>.
  895.  
  896.