HOWTO: The Computer Classroom July 7, 2001  
 
 

2.1.3 Print Service

Your next step should be to get your printer functioning. You will probably run into any of these three types of printers, (1) one that is connected directly to your computer’s parallel port, (2) one that is accessible through a network, or (3) an AppleTalk or Windows printer. Chances are, you have your own printer to work with in your lab or classroom, and it’s probably a networked laser printer, option 2 above. If this is the case, your printer will have its own IP address, too; find out what it is from your network administrator. I suggest using the LPRng protocol for your print server; the other option is lpd, but they both work the same, and LPRng gives you more options.

Basically, your printer configuration will depend a great deal on the kind of printer you have. Since my lab has a Hewlett Packard, and many laser printers on the market today work in a similar way, the rest of this example will outline the configuration of our HP8000. First, we’ll install the ifhp package which will provide more options for our printer. To get this program, we’ll use the wget package we installed above. Type each of these lines in order:

wget ftp://ftp.lprng.com/pub/LPRng/FILTERS/ifhp-3.4.4-1.i386.rpm
rpm -Uvh ifhp-3.4.4-1.i386.rpm

This will download and install the ifhp package. The executable part of the program is installed in /usr/local/libexec/filters/ifhp; you’ll need this information for configuring the /etc/printcap file.

The /etc/printcap file contains information about how your server has to communicate with your printer. This file is particular about how you enter the information, so be precise and double-check your work. To enable our HP8000, my server’s /etc/printcap file looks like this:

hp8000|HP8000|HP LaserJet 8000:\
     :lp=192.168.200.90%9100:sd=/var/spool/lpd/hp8000:\
     :lf=/var/spool/lpd/hp8000/log:\
     :mx#0:sh:\
     :if=/usr/local/libexec/filters/ifhp:\
     :of=/usr/local/libexec/filters/ofhp:

I chose the short name “hp8000” for my printer, but you can choose anything you want. My printer’s IP address is 192.168.200.90 and “%9100” is the TCP port that it will use for connecting to the printer. The “sd” is the printer’s spool directory, and “lf” points to the printer’s log file; “mx#0” does not limit the size of the file to be printed, and “sh” suppresses that printer’s header. The latter two lines point to the filters that we installed above. This is the simplest /etc/printcap file I could make. For more options, see Brian Ward’s The Linux Problem Solver, Chapter 5.

To make your changes take effect, type:

/etc/rc.d/init.d/lpd restart

This command will restart the printer daemon and configure the system to print using the specifications you entered in /etc/printcap. If the daemon restarts without an error, you need to test the printer by typing:

lpr /etc/hosts

The /etc/hosts file should, after a second or two, print. If it does not, check your numbers and /etc/printcap file again to make sure you entered everything correctly. Finally, you will need to know two commands for printer maintenance: lpq and lprm. The former allows you to see the print queue, and the latter allows you to clear a job in the queue by entering the job’s number after the command. Otherwise, once you install and configure the printer successfully, it should just run. Oh, you might have to put paper in the printer itself from time to time.

 
   
 
© 2001 by grlucas.com; all rights reserved