Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 May 2000 16:06:40 -0400
From:      "James Halstead" <halstead@dreamscape.com>
To:        <tim.614@funbox.demon.co.uk>
Cc:        <freeBSD-hackers@freebsd.org>
Subject:   Re: smb printer trouble
Message-ID:  <000701bfc104$96206a80$69c3d9d1@halste07>
References:  <3923D7A2.55A0@funbox.demon.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks, and no-thanks at the same time ;)

The 'push back' will help (so I can avoid the temp file) and I will put that
in.
However, my filter is doing just fine on postscript files (and since it is a
postscript pinter I
don't have to put it through gs). The problem is with _non_ postscript files
where the first
line contains the '\' char at the end of the line, the read procedure sees
that as "chomp the newline,
and keep going as if the line never ended" I need to see if there is a way
to avoid that behavior so
my filter can print all files without messing them up ;)

Thanks for the 'push back' help though!

James.

----- Original Message -----
From: <tim.614@funbox.demon.co.uk>
To: "James Halstead" <halstead@dreamscape.com>
Sent: Thursday, May 18, 2000 7:44 AM
Subject: Re: smb printer trouble


>
> > Actually, if there is a way that I can read only the first two
> > chars from the standard input that would solve the problem for
> > nearly all the cases. I only need the first two chars to do my
> > test, then I can leave the rest up to cat. It would be even better
> > if sombody could tell me a way to push chars back on to the stdin
> > stream that way I can completly avoid making a temporary file.
>
> I don't know if this will help;  I filched it from a simple printer
> filter example that is somewhere in the distribution.  It's a shell
> script that checks the first few characters (on stdin) to see if it's
> getting a PostScript file or something else.
>
> #!/bin/sh
>
> Esc="\033"
>
> printf "${Esc}E" || {
>     logger "lp filter: error resetting printer"
>     printf "lp filter: error resetting printer\n" >&2
>     exit 0 # delete job from queue
> }
>
> read First_line
> Magic=$(expr "$First_line" : '\(....\)')
>
> case $Magic in
>
>     %!PS)
>         /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=cdj550 \
>             -sPAPERSIZE=a4 -sOutputFile=- - && exit 0
>         ;;
>
>     ~lpx)
>         Found_end=0
>         Type=nil
>         while [ ${Found_end} -eq 0 ]
>         do
>             read Keyword Value
>             case ${Keyword} in
>                 type)    Type=${Value};;
>
> ... and so on.
>
> If the first 4 characters ('$Magic') are '%!PS', everything from stdin
> is slurped up by /usr/local/bin/gs, which interprets it to stdout and
> then exits.
>
> You'll notice that the first line of stdin does not go to gs (which
> doesn't need it).  If it had been necessary to 'push back' that first
> line, it would have been easy, e.g.:
>
>     (echo $First_line; cat) | /usr/local/bin/gs
>
>
>
>
> I hope this has been of some help...
>
> -- Tim Jackson
>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000701bfc104$96206a80$69c3d9d1>