i plan on compiling a bunch of short tutorials for the IF's.  here's the first
one, on configuring printers under linux.

it's from various sources and i added my own info.  i'd appreciate any
technical/style comments.  it's for the IF, but other people may want to
take a look at it too.  all comments, emailed to me directly, are very
welcome!

pete



Table Of Contents
-----------------
Configuring a printer under linux.
If you need to set up a text filter.
Setting up a remote printer on linux.


****     If this is a Redhat machine, there's an excellent GUI tool called 
note     printtool.  Try to use this first if you're on a Redhat machine.
****     If it fails, then proceed with this document.


Configuring a printer under linux
=================================

Most PC's have a single parallel port.  A printer on that port would be
connected to /dev/lp0.  If the PC has more than one parallel port (or if you
added a printer card), the 2nd port would be /dev/lp1.


Test 1
------
You should be able to print direcly to the printer.  As a first stab, try:

        echo "This is a test." > /dev/lp0
        echo "Please ignore." > /dev/lp0
        echo "" > /dev/lp0

The last line sends a line feed which ejects the page.  If you see something
like:

   This is a test.
                  Please ignore.

this is the 'staircase effect'.  It's caused by the printer expecting DOS text
(which ends with carriage return and a line feed), instead of linux text
(which ends only with a line feed).  To get things right, you need to set up a
text filter.  It's quite possible that there's already a text filter in place.


Test 2
------
We'll see if a text filter is already in place.  Create a test textfile named
testfile containing:

        This is a test.
        Please ignore.

Try printing it with

        lpr testfile

If everything comes out satisfactory, then stop reading because you're done.
If you see the staircase effect, continue reading.




If you need to set up a text filter
===================================

Step 1
------
Create an executable named /var/spool/lpd/textfilter with permission 755. 
Verify that perl is located at /usr/bin/perl.

        #!/usr/bin/perl
        # This script must be executable: chmod 755 filter
        while(<STDIN>){chop $_; print "$_\r\n";};
        print "\f";


Step 2
------
Try printing the testfile by:

        cat testfile | /var/spool/lpd/textfilter > /dev/lp0

This should produce satisfactory results.  If it does, then we need to modify
/etc/printcap to make printing convenient.


Step 3
------
Edit /etc/printcap and add the lines (leave out comments if you like):

myprinter:\                          # name of logical printer
        :sd=/var/spool/lpd/myqueue:\      # name of queue
        :mx#0:\                           # maximum file to print; 0=unlimited
        :sh:\                             # suppress header page
        :lp=/dev/lp0:\                    # name of physical printer
        :if=/var/spool/lpd/textfilter:    # input filter to use


Step 4
------
Create /var/spool/lpd/myqueue with permission 777.


Step 5
------
Try printing the testfile again, this time with the queue you just made.

        lpr -Pmyprinter testfile


Step 6
------
In /etc/profile, add the following line to make myprinter the default:

        export PRINTER=myprinter

Don't forget to source /etc/profile before continuing!


Step 7
------
Try printing again, without specifying the printer to use:

        lp testfile

If everything goes right, you're done.




Setting up a remote printer under linux
=======================================
Suppose you have two linux machines, farlinux (which has a printer) and
nearlinux (which wants to use the remote printer).  

Step 1
------
Create the following entry in /etc/printcap on nearlinux:

remoteprinter:\                    # name of logical printer
        :sd=/var/spool/lpd/farlinux:\   # name of queue
        :mx#0:\                         # maximum filesize to print; 0=unlimited
        :sh:\                           # supress header page
        :rm=farlinux:\                  # name of remote host which has the printer
        :rp=myprinter:                  # name of logical printer on farlinux

Note that the lp directive (which defines the physical printer) is gone.
We have a rm directive which gives the hostname of the computer which has
the printer we want to use.  The rp directive names which logical printer
to use on the machine specified by rm.

Step 2
------
The only thing left to do is tell farlinux that we want to give printing
permission to nearlinux.  Edit the file /etc/hosts.lpd and add nearlinux, or
better yet, its IP address.  Be careful if nearlinux has two IP addresses
(maybe it's a gateway?).  Use the IP address that farlinux knows about.

Step 3
------
Restart lpd on farlinux.

Step 4
------
Test printing a file on nearlinux.

Reply via email to