I have setup my system so that it can print in both text and postscript mode to an HP LaserJet 4.
#start of printcap
hp4:\
:lp=/dev/hp4:\
:sd=/var/spool/lpd/hp:\
:af=/var/spool/lpd/hp/acct:\
:mx#0:\
:if=/usr/local/print/texthp4:
ps4:\
:lp=/dev/ps4:\
:sd=/var/spool/lpd/ps:\
:af=/var/spool/lpd/ps/acct:\
:mx#0:\
:if=/usr/local/print/pshp4:
#end of printcap
bash# touch /dev/hp4 bash# touch /dev/ps4 bash# chmod 777 /dev/hp4 bash# chmod 777 /dev/ps4
bash# mkdir /var/spool/lpd/hp bash# mkdir /var/spool/lpd/ps bash# checkpc -fAfter running checkpc, create anything that it has trouble finding, usually it is log and lock files.
The plain text filter :
#!/bin/sh -x
#
# /usr/local/print/texthp4
#
# Plain text printing to an HP laserjet 4
#
logfile=/tmp/smb-print.log
(
echo translate
echo "print -"
cat
echo -e "\f"
) | /usr/local/samba/bin/smbclient "\\\\OBSLON2\\mktghp4" password -U username -N -P >>$logfile
#end of texthp4
#!/bin/sh -x
#
# /usr/local/print/pshp4
#
# Postscript printing to an HP Laserjet 4
#
logfile=/tmp/smb-print.log
(
echo "print -"
/usr/bin/gs -dSAFER -dNOPAUSE -sPAPERSIZE=a4 -q -sDEVICE=ljet4 -sOutputFile=- -
printf "\014"
) | /usr/local/samba/bin/smbclient "\\\\OBSLON2\\mktghp4" password -U username -N -P >>$logfile
#end of pshp4
Ensure that you have an entry for the NT server in your /etc/hosts file. Mine looks like this :
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
#
and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
#
For loopbacking.
127.0.0.1 localhost
1.0.12.17 lynx.obs lynx (my linux box)
1.0.21.125 OBSLON2
# End of hosts.
/sbin/route add -net 1.0.21.0 netmask 255.255.255.0 eth0
bash# /usr/local/samba/bin/nmblookup -B 1.0.21.125 OBSLON2
1.0.21.125 OBSLON2
bash# lpd
If it is already running then,
bash# lpd lpd: Fatal error - Another print spooler is using TCP printer port, possibly lpd process '4788' bash# kill -9 4788 bash# lpd
bash# lpr -Php4 /usr/local/print/texthp4
And wait to see what (if anything) appears
To test out the postscript mode, well use something that generates postscript (netscape for example, or ez-andrew) and print to queue ps4.
If you do not have some output generated, well, either your printer is offline, your printer daemon has a problem, or I was *very* lucky to get mine working in the first place.
Mark W J Redding, 2nd March 1998
本文转自中文Linux论坛