"Linux Gazette...making Linux just a little more fun!"


How to print to a Printer on a Netware server

By Izak Burger


Introduction


To understand the circumstances which led to me writing this little article, I have to explain a few things first. I am a student at the university of Stellenbosch in South Africa. We have a lot of Netware Servers on Campus, and most of the printers used by students are connected to one of these servers. A while ago I installed Linux for two friends of mine. They were quite impressed with the performance, and after a while the decision was made to install Linux on two of the other computers too. To make the switch from Windows to Linux as smooth as possible, one of the requirements of the new setup was that the Linux PC's should be able to print to the Netware printer upstairs, without any aditional steps (Saving as text, converting to postscript, and printing with nprint), in other words, point and click the way windows users do it all the time. This article explains how I did it.

This article assumes that you'll be using only one printer, that is the Netware printer. Because this procedure includes replacement of the print spooler daemon, I do NOT recommend this procedure for a working installation with one or more printers (unless of course you know what you're doing, but then you won't be reading this now would you? :) ). Also, most of the instructions are rather Redhat specific, if you are using another distribution, ask someone to translate :)


How does it work?


A print spooler is a program that accepts print jobs from computers on the network. Usually the print jobs are stored on disk until the printer becomes available again. The print spooler program also places an exclusive lock on the device your printer is connected to, usually /dev/lp1. This prevents other users or programs from printing while the print spooler is busy.

The print spooler does however do no formatting of its own. It merely stores what ever you sent it in a disk file, then send it to the printer when it becomes available. To have some kind of intelligent formating, filters are used. A print filter will determine the type of data passing through it, and peform conversions on it. This means that it doesn't matter what you send to the printer, the printer will always get something printable, usually postscript.

Filters also makes it possible to do a few nice things. Since a filter is actually nothing more than a small program that reads from stdin and writes to stdout, we can write filter programs that can do almost anything. In this case, I made it send the job to a Netware server.


Requirements

You need the latest versions of:

Note: The location or version numbers of these software may have changed.


Installation

You have to be root to install this.

If you havent already done so, recompile your kernel with ipx support, but not full internal net. You may also compile ipx as a module. See the Kernel- HOWTO for more information about this.

Install ncpfs with: rpm -i ncpfs-2.0.11-3.i386.rpm (Your version number may differ)
You may also need to install ipx-utils. Rpm will notify you if you haven't installed ipx-utils yet.

Execute one of the following, depending on your setup. In my case the first line worked perfectly on all of the systems I have installed this on:

You may also want to read the man pages for these commands. Since you want to print to a netware server, I assume you have access to it, and should not have a problem obtaining the correct settings here. You should also put this line in /etc/rc.d/rc.local, so that it gets executed everytime you boot your system.

You have to remove the existing lpd before installing LPRng, this is most easily acomplished with:

/etc/rc.d/init.d/lpd stop
rpm -e printtool
rpm -e rhs-printfilters
rpm -e lpr

Extract the LPRng- and magicfilter tarballs into /usr/local/src (or anywhere else you feel comfortable with), they should untar into their own subdirectories. Now follow the directions given in the README or INSTALL files of both, this usually consists of a ./configure, make, make install.

Create the directory /usr/local/printfilters and copy a suitable filter from /usr/local/src/magicfilter-1.2/filters to this directory. You may need to modify this file slightly to make it work propperly. In my case i used the psonly600-filter file: on rh5.1 a2ps was invoked with bad parameters; on rh5.0 a2ps wasn't installed and nowhere to be found on the cdrom, so i had to add this to the file:

default pipe mpage -ba4 -o -1

or install nenscript (from redhat cd) and add this line (this is probably the best option):

default pipe /usr/bin/nenscript -b -p-

Also, change these lines:

# postscript
0%!postscript
0\004%!postscript
to this:

# postscript
0%!cat
0\004%!cat

This is because "postscript" caused an extra clean page to be printed after every print job.

I also include this filter. It was orriginally used to print to a HP laserjet 4000.

Copy nwprint, filter and .config to /usr/local/printfilters, then edit filter and replace psonly1200-filter with the filter you intend to use.

Edit the .config file to contain the information relevant to your setup.

Now do:

 
	chmod 755 filter nwprint
	chmod 640 .config
	chown root.daemon .config

Install the lpd startup script in /etc/rc.d/init.d. remember to do a chmod 755 /etc/rc.d/init.d/lpd.

Now you have to make symlinks to start lpd in the correct runlevels:

cd /etc/rc.d/rc3.d
ln -s ../init.d/lpd s90lpd
cd /etc/rc.d/rc5.d
ln -s ../init.d/lpd s90lpd
cd /etc/rc.d/rc6.d
ln -s ../init.d/lpd k08lpd
cd /etc/rc.d/rc0.d
ln -s ../init.d/lpd k08lpd

This should have lpd start up in the runlevels mostly used by Redhat users.

Now we get to modifying a bunch of files in /etc...
Edit /etc/printcap to look like the following:

lp:\
:sd=/var/spool/lpd/lp:\
:mx#0:\
:sh:\
:if=/usr/local/printfilters/filter:\
:af=/var/spool/lpd/lp/acct:\
:lp=/dev/null:

Edit /etc/lpd.conf and locate the line:

# Purpose: lock the IO device
# lk@

Uncomment the "lk@". This tells lpd NOT to place an exclusive lock onto the device, so if any other program tries to use /dev/null while we're printing it will not break.

Edit /etc/lpd.perms and add these lines:

REJECT NOT SERVER
REJECT SERVICE=R,P,Q,M,C,S NOT REMOTEUSER=yourusername,another,friend

This allows only the users in the comma separated list to print from the local host. I dont know what will happen if two users print at exactly the same time, but for the most part you will only allow yourself to print anyway.

Finally execute:

checkpc -f
/etc/rc.d/init.d/lpd start

Everything should work propperly now. You should now clean up /usr/local/src. Keep the tarballs in a safe place, then do this:

rm -rf /usr/local/src/magicfilter-1.2
rm -rf /usr/local/src/LPRng-3.5.1


Why it took me a week to figure this out...

I tried to do the same thing with lpd, but for some sinister reason nprint could not access any Netware servers if it was invoked by lpd. If the filter was invoked from the commandline, only then could nprint access the server and print the job. I had a few options: Figure out a way of forcing lpd to allow me access, produce a kind of work arround, or use another spooler. Since lpd already have lots of other problems (Read about it, never seen them in action), I settled for LPRng.

At first I tried to make the standard Redhat print filter work with LPRng. This did not work very well, because the standard filter use files in /var/spool/lpd/lp while LPRng is rather fussy about the permisions of files in this directory. Moving the files broke everything, and as it was already 3:00 on a Saturday morning by then, I quickly got magicfilter off sunsite (We have a local mirror :) ), compiled the software and built myself a little filter script.

Now all I had to do was introduce some kind of password hiding mechanism so that users of the system cannot see the Netware username and password. I discovered that the filter was executed as the "daemon" user, therefore decided to create a .config file with permisions 640 and ownership root.daemon. This file is simply included into nwprint, but while anyone can read nwprint, no one can read .config ( except root and daemon of course :) ).

Well this allowed any user with access to the system to print, usually you would only want yourself to have access to the printer, so after reading through /etc/lpd.perms and part of the documentation, I came up with the two REJECT lines mentioned above.


A few useful tips

Or rather, things I discovered while doing this...

1. To test the setup, change the nwprint script to cat all input to a file in /tmp. This is also nice to produce postscript files from applications that do not have the capability to save in postscript: Just uncomment the "cat > /tmp/printout.ps" line in the nwprint script. Of course you'll have to comment the nprint line out :) You can even have this installed as a second "Printer", together with your existing printer.

2. To print from pine, you have to setup lpr as default printing command rather than the other default thingy it uses.

3. Use the Generic postscript option in StarOffice. Even if you don't have a postscript printer, you should be able to use it as long as ghostscript has a driver for your printer.

4. Look in /pub/Linux/system/printing on sunsite.unc.edu for other print filters. There's plenty of existing solutions for most of the Canon bubble jet printers, as well as HP deskjets and some of the Epson printers.

Also read the Printing-HOWTO, it should be installed in /usr/doc/HOWTO but if it is not there, locate the RPM on your Redhat 5.0/5.1 CD and install it, having the howto's arround is always nice, and is in my oppinion a MUST.


DISCLAIMER


This is the place where I tell you that I am not responsible for any harm that may come to you or your computer as a result of following the steps in this article. Blah Blah...

If I did anything stupid or there are better ways to do this please let me know at the e-mail address below, this address should be valid at least until somewhere late in 1999 :)

Izak Burger
gpf@pikkedil.energie.sun.ac.za


Copyright © 1998, Izak Burger
Published in Issue 34 of Linux Gazette, November 1998


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next