can't print postscript files

Malcolm Kay malcolm.kay at internode.on.net
Thu May 22 08:31:21 PDT 2003


On Fri, 23 May 2003 00:08, tollallenamensindbelegt at t-online.de wrote:
> Hi I,
> had configure my /etc/printcap like the example in the freebsd handbook but
> I'm not able to print postscript files I thing I  have a little misstake in
> the gs section in this script /usr/local/libexec/hl7x0 because I can print
> plaintext files.
>
> my printer is a brother HL-730
>
> could any one give me the answer where is the misstake that I'm not able to
> print ps file.
>
> thanks!!!
>
> best regards
>
> Michael Bohn
>
> mailto: tollallenamensindbelegt at t-online.de
>
>
>
> /etc/printcap
>
> #
> lp|brother730:\
>
>         :sh:sd=/var/spool/lpd/brother730:\
>         :lp=/dev/lpt0:\
>         :if=/usr/local/libexec/hl7x0:\
>         :df=/usr/local/libexec/psdf:
>
> #
>
> #################################################################
>
> #!/bin/sh
> #
> #  ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500
> #  Installed in /usr/local/libexec/hl7x0
>
> #
> #  Treat LF as CR+LF:
> #
> printf "\033&k2G" || exit 2
>
> #
> #  Read first two characters of the file
> #
> IFS="" read -r first_line
> first_two_chars=`expr "$first_line" : '\(..\)'`
>
> if [ "$first_two_chars" = "%!" ]; then
>
>     #  It is PostScript; use Ghostscript to scan-convert and print it.
>     #
>     #  Note that PostScript files are actually interpreted programs,
>     #  and those programs are allowed to write to stdout, which will
>     #  mess up the printed output.  So, we redirect stdout to stderr
>     #  and then make descriptor 3 go to stdout, and have Ghostscript
>     #  write its output there.  Exercise for the clever reader:
>     #  capture the stderr output from Ghostscript and mail it back to
>     #  the user originating the print job.
>     #
>     exec 3>&1 1>&2
>     /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=hl7x0 \
>         -sOutputFile=/dev/lpt0 - && exit 0

'lpd' expects the fifter output on STDOUT which from the exec command 
comes from the redirected file descriptor 3. So the gs output should be 
specified -sOutputFile=/dev/fd/3 which is another of addressing file 
descriptor 3. The final destination of /dev/lpt0 comes from printcap.

> else
>     #
>     #  Plain text or HP/PCL, so just print it directly; print a form feed
>     #  at the end to eject the last page.
>     #
>    echo "$first_line" && cat && printf "\033&l0H" &&
> exit 0
> fi
>
> exit 2
>
> ###########################################################################




More information about the freebsd-questions mailing list