From owner-freebsd-questions@FreeBSD.ORG Sun Oct 1 22:13:03 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 E834716A416 for ; Sun, 1 Oct 2006 22:13:03 +0000 (UTC) (envelope-from kline@sage.thought.org) Received: from sage.thought.org (dsl231-043-140.sea1.dsl.speakeasy.net [216.231.43.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3B4DF43D53 for ; Sun, 1 Oct 2006 22:13:02 +0000 (GMT) (envelope-from kline@sage.thought.org) Received: from sage.thought.org (kline@localhost [127.0.0.1]) by sage.thought.org (8.13.6/8.12.10) with ESMTP id k91MCwDA088825; Sun, 1 Oct 2006 15:12:58 -0700 (PDT) (envelope-from kline@sage.thought.org) Received: (from kline@localhost) by sage.thought.org (8.13.6/8.13.1/Submit) id k91MCvar088824; Sun, 1 Oct 2006 15:12:57 -0700 (PDT) (envelope-from kline) Date: Sun, 1 Oct 2006 15:12:57 -0700 From: Gary Kline To: Ian Smith Message-ID: <20061001221256.GA88740@thought.org> References: <20061001012822.7EA2C16A591@hub.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: Observing twenty years of service to the Unix community User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Gary Kline , freebsd-questions@freebsd.org Subject: Re: triouble with my Deskjet 500 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Oct 2006 22:13:04 -0000 On Mon, Oct 02, 2006 at 02:49:56AM +1000, Ian Smith wrote: > Re: freebsd-questions Digest, Vol 152, Issue 13 > On Sun, 1 Oct 2006 freebsd-questions-request@freebsd.org wrote: > > Message: 30 > > Date: Sat, 30 Sep 2006 17:12:10 -0700 > > From: Gary Kline > > Subject: triouble with my Deskjet 500 > > Hi Gary, > > > The trouble is that it only prints in ASCII Aand fails to fails > > to print xv images or anything else PostScript. I'm playing > > around withthe following in /usr//local/libexec: > > [[ ... ]] > > It's pretty obviously that I can toss the first several lines that > > came from the original hpif file; this was before I cared about > > graphics. I lost the ghostscript part when my system had its > > fatal trap. Anybody out there who has an ancient hp djet500? > > or can help otherwise. I'm out of ideas. > > I ran into exactly this after upgrading 4.5-R to 5.4-R (now 5.5-S); that > fancy stderr/stdout dance doesn't seem to work &/| be needed anymore. I > got sick of Mozilla crashing trying to print and dug up this fix, forget > where/how. Way over commented, but times like this it comes in handy :) > > #!/bin/sh > #% /usr/local/libexec/if-lq850 smithi 6/4/3 > #% v2 29/6/6, maybe the 3>&1 stuff is what doesn't work in 5.4-R? > #% as advised by FreeBSD handbook, from: > # ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500 > # as installed in /usr/local/libexec/hpif > #% modified for printer canon bj10sx (configured as an epson lq850) > After fmessing around for an hour I found the bug that was introduced by the new/"improved"/(free) CUPS' lp*. The *only* script change [[ at least that I can see ]] is that "sOutputFile=" now fails to understand /dev/fd/3. I got my old "hpif working with only-ASCII and your version working with only-[Gh|P]ostscript, or mostly since your file did print some ASCII. But for me, it hung for some timeout or . I dropped in your Postscript working lines, minus the re-direction stuff and voila! Yes for good old fashioned ASCII and Postscript both. Appended if my new hpif. (I have four servers with /usr/local/libexec/hpif, so name-change rather than change four /etc/printcaps:-). thankee, thankee! gary PS: file appended. note lines 39-46... . PPS: comments appreciated; it's hard to *overcomment*, IMHO. -- Gary Kline kline@thought.org www.thought.org Public service Unix 1 #!/bin/sh 2 # 3 # hpif - Simple text input filter for lpd for HP-PCL based printers 4 # Installed in /usr/local/libexec/hpif 5 # 6 # Simply copies stdin to stdout. Ignores all filter arguments. 7 # Tells printer to treat LF as CR+LF. Writes a form feed character 8 # after printing job. 9 10 ###printf "\033&k2G" && cat && printf "\f" && exit 0 11 12 # 13 # ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500 14 # Installed in /usr/local/libexec/ifhp 15 16 # 17 # Treat LF as CR+LF: 18 # 19 printf "\033&k2G" || exit 2 20 21 # 22 # Read first two characters of the file 23 # 24 IFS="" read -r first_line 25 first_two_chars=`expr "$first_line" : '\(..\)'` 26 27 if [ "$first_two_chars" = "%!" ]; then 28 # 29 # It is PostScript; use Ghostscript to scan-convert and print it. 30 # 31 # Note that PostScript files are actually interpreted programs, 32 # and those programs are allowed to write to stdout, which will 33 # mess up the printed output. So, we redirect stdout to stderr 34 # and then make descriptor 3 go to stdout, and have Ghostscript 35 # write its output there. Exercise for the clever reader: 36 # capture the stderr output from Ghostscript and mail it back to 37 # the user originating the print job. 38 # 39 ###exec 3>&1 1>&2 40 ###/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \ 41 ###-sOutputFile=/dev/fd/3 - && exit 0 42 43 44 45 /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \ 46 -sOutputFile=- - && exit 0 47 48 else 49 # 50 # Plain text or HP/PCL, so just print it directly; print a form feed 51 # at the end to eject the last page. 52 # 53 echo "$first_line" && cat && printf "\033&l0H" && 54 exit 0 55 fi 56 57 exit 2