Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.vbc.net!vbcnet-west!bulb.garlic.com!news.scruz.net!kithrup.com!news.Stanford.EDU!su-news-hub1.bbnplanet.com!news.bbnplanet.com!zdc!super.zippo.com!news.onramp.net!news.nkn.net!news.panther.net!nemesis!hammy!news-in.iadfw.net!news.gymnet.com!LSNT1!lsbsdi6.lightspeed.net!news3.crl.com!nntp3.crl.com!news.infomagic.com!news-out.internetmci.com!newsfeed.internetmci.com!news.metamall.com!tomahawk.network-one.com!ze phyr.texoma.net!kane.uswmedia.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!math.ohio-state.edu!jussieu.fr!oleane!weld.news.pipex.net!pipex!warm.news.pipex.net!pipex!tank.news.pipex.net!pipex!news.utell.co.uk!usenet From: brian@shift.utell.net (Brian Somers) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Printing with FreeBSD 2.1.6 Date: 21 May 1997 10:29:57 GMT Organization: Awfulhak Ltd. Lines: 76 Message-ID: <63664E685B1B5E5B.D3F94E88FF57EB0C.D85BF1E1322A3180@library-proxy.airnews.net> X-Orig-Message-ID: <5luir5$39p@ui-gate.utell.co.uk> References: <33821625.1F2210DB@cyberworld.demon.co.uk> Reply-To: brian@awfulhak.org, brian@utell.co.uk NNTP-Proxy-Relay: library.airnews.net NNTP-Posting-Host: biceps.gymnet.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Newsreader: knews 0.9.8 Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:41697 In article <33821625.1F2210DB@cyberworld.demon.co.uk>, Lee Johnston <ljohnston@cyberworld.demon.co.uk> writes: > 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! This works ok for me: shift:/tmp $ cat xxx #!/bin/sh read first_line first_two_chars=`expr "$first_line" : '\(..\)'` echo $first_two_chars && exit 0 exit 2 shift:/tmp $ echo hello | ./xxx he shift:/tmp $ Are you sure your quotes are the correct ones ? I find it clearer to use the $(command) syntax rather than the `command` syntax. > ______ > Lee Johnston > ljohnston@cyberworld.demon.co.uk > http://www.cyberworld.demon.co.uk > -- Brian <brian@awfulhak.org> <brian@freebsd.org> <http://www.awfulhak.org> Don't _EVER_ lose your sense of humour !