*BSD News Article 95837


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.edu.au!munnari.OZ.AU!news.mel.connect.com.au!news.syd.connect.com.au!phaedrus.kralizec.net.au!news.mel.aone.net.au!news.netspace.net.au!news.mira.net.au!inquo!nntp.uio.no!news.maxwell.syr.edu!disgorge.news.demon.net!demon!dispatch.news.demon.net!demon!cyberworld.demon.co.uk!not-for-mail
From: Lee Johnston <ljohnston@cyberworld.demon.co.uk>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Printing with FreeBSD 2.1.6
Date: Tue, 20 May 1997 22:22:47 +0100
Message-ID: <33821625.1F2210DB@cyberworld.demon.co.uk>
NNTP-Posting-Host: cyberworld.demon.co.uk
X-NNTP-Posting-Host: cyberworld.demon.co.uk [158.152.125.109]
X-Mailer: Mozilla 4.0b3 [en] (Win95; I)
MIME-Version: 1.0
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=iso-8859-1
Lines: 53
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:41336

I am using FreeBSD 2.1.6 with a non postscript printer (a Canon BJC-4100
Bubble Jet simulating a Epson LQ). I have managed to get ghostscript to
printout a .ps file on the printer, but when I create a printer filter
that is included in the FreeBSD handbook, which is shown below, it
doesn't work!

#!/bin/sh
#
#  ifhp - Print Ghostscript-simulated PostScript on a Canon BJC-4100
#  Installed in /usr/local/libexec/hpif
#
#  Treat LF as CR+LF:
#
printf "\033&k2G" || exit 2
#
#  Read first two characters of the file
#
read first_line
first_two_chars=`expr "$first_line" : '\(..\)'`
if [ "$first_two_chars" = "%!" ]; then
    #
    #  It is PostScript; use Ghostscript to scan-convert and print it
    #
    /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=epsonc
-sOutputFile=- - \
        && exit 0
else
    #
    #  Plain text or HP/PCL, so just print it directly; print a form
    #  at the end to eject the last page.
    #
    echo $first_line && cat && printf "\f" && exit 2
fi
exit 2

I suspect that it may be the line ' first_two_chars=`expr "$first_line"
: '\(..\)'` ' as when I try a simple filter shown below, to echo the
result of the ' first_two_chars=`expr "$first_line" : '\(..\)'` ' line
to the printer, if only prints out ' expr "$first_line" : '\(..\)' '.

#!/bin/sh
read first_line
first_two_chars=`expr "$first_line" : '\(..\)'`
echo $first_two_chars && exit 0
exit 2

Has anyone come across this problem, and how do I solve it, Thanks!

______
Lee Johnston
ljohnston@cyberworld.demon.co.uk
http://www.cyberworld.demon.co.uk