From owner-freebsd-questions Wed Mar 5 19:46: 5 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D32C37B401 for ; Wed, 5 Mar 2003 19:46:03 -0800 (PST) Received: from wonkity.com (wonkity.com [65.173.111.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id A159E43FDD for ; Wed, 5 Mar 2003 19:46:02 -0800 (PST) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.12.8/8.12.8) with ESMTP id h263jPIg004120; Wed, 5 Mar 2003 20:45:25 -0700 (MST) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.12.8/8.12.8/Submit) with ESMTP id h263jOIf004117; Wed, 5 Mar 2003 20:45:25 -0700 (MST) Date: Wed, 5 Mar 2003 20:45:24 -0700 (MST) From: Warren Block To: darren_spruell@sento.com, "" , "" Subject: Re: printing to HP LaserJet 4050 TN In-Reply-To: <3E661A45.9060504@sento.com> Message-ID: <20030305201455.Y4052@wonkity.com> References: <3E64E658.5080108@sento.com> <20030304170655.O45239@wonkity.com> <3E661A45.9060504@sento.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 5 Mar 2003, Darren Spruell wrote: > I've seen a couple of sample scripts, but if you have one that works > specifically with Laserjet, that would suit :) Ah, that's the beauty of it--it works with any PostScript printer. (Or non-PostScript... see below.) First, the /etc/printcap: # /etc/printcap lp:\ :lp=/dev/null:\ :sh:\ :mx#0:\ :lf=/var/log/lpd-errs:\ :sd=/var/spool/output/lpd/lp:\ :if=/usr/local/libexec/checkps: lpraw:\ :lp=:\ :sh:\ :mx#0:\ :rm=laser:\ :rp=raw:\ :sd=/var/spool/output/lpd/lpraw:\ :lf=/var/log/lpd-errs: # end You have to create the spool directories: /var/spool/output/lpd/lp and lpraw. I chmod them to daemon:wheel and chmod them to 600. "laser" is the hostname of the printer in /etc/hosts. When you print to lp, the input filter (if=) called checkps sees if the incoming file is PostScript. It also detects HP PJL PostScript jobs, which the example given in the Handbook does not. If the job is PostScript, it sends it to the lpraw queue, which is the real printer. If the job is not PostScript, it uses Enscript to format it and then sends it to lpraw. If you know your job is PostScript, you can send it straight to lpraw in the first place. Here's the /usr/local/libexec/checkps program (the fourth line should not wrap): #!/usr/bin/perl # Warren Block 01-15-2003 $_=; $outname = /^%!|\e%/ ? '| /usr/bin/lpr -Plpraw' : '| /usr/local/bin/enscript -Plpraw'; open(PRT, $outname) or die "can't open pipe: '$!'\n"; print PRT $_; while () { print PRT $_; } close(PRT); chmod +x the Perl program, and install the print/enscript-letter port. If you want other computers to be able to print to this one, add their hostnames to /etc/hosts.lpd. Not the most efficient of filters, but it's simple and hasn't failed. If the printer is PCL only, Ghostscript can be added to convert the PostScript output to PCL. -Warren Block * Rapid City, South Dakota USA To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message