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 [EMAIL PROTECTED] wrote:
>  > Message: 30
>  > Date: Sat, 30 Sep 2006 17:12:10 -0700
>  > From: Gary Kline <[EMAIL PROTECTED]>
>  > 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     [EMAIL PROTECTED]   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
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to