Hi, In trying to track down a problem in printing to a PostScript printer (which turned out to be a problem NOT with Red Hat but with the printer itself), I found what might be a problem with one of the utility programs in /usr/lib/rhs/rhs-printfilters: rewindstdin. If you feed a PostScript file into the /var/spool/lpd/*/filter that is installed for a generic PostScript printer, you will see that, the first time that the variable "magic" is found, it takes a value like this: magic=standard input: PostScript document text ... At the second point that the variable "magic" is computed, however, it gets a value like this: magic=standard input: English text My suspicion is that the "rewindstdin" program doesn't work the way that the author of "filter" thinks. In any case, there is a little bit of extra work being done in "filter" that can be avoided. Here is a diff file that I created for the generic PostScript print filter. Note, though, that I still think that "rewindstdin" isn't working as the author believes it should. Cheers, Tony Kocurko - Memorial University of Newfoundland --------------- here is the diff file --------------------- *** filter Tue Sep 14 12:03:34 1999 --- filter.new Tue Sep 14 12:03:57 1999 *************** *** 166,193 **** # Figure out the magic of the input file # magic=$(file -) - $FPIDIR/rewindstdin magic=${magic#*: } if [ "$DEBUG_FILTER" != "" ]; then echo "Magic is |$magic|" >> /tmp/filter.debug fi case `echo $magic | tr 'A-Z' 'a-z'` in *packed*|*gzip*|*compress* ) ! DECOMPRESS="gzip -dc";; * ) ! DECOMPRESS="";; esac - - # - # Figure out the magic of the input file - # - if [ "$DECOMPRESS" = "" ]; then - magic=$(file -) - else - magic=$($DECOMPRESS - | file -) - fi $FPIDIR/rewindstdin ! magic=${magic#*: } if [ "$DEBUG_FILTER" != "" ]; then echo "Magic is |$magic|" >> /tmp/filter.debug fi --- 166,187 ---- # Figure out the magic of the input file # magic=$(file -) magic=${magic#*: } if [ "$DEBUG_FILTER" != "" ]; then echo "Magic is |$magic|" >> /tmp/filter.debug fi case `echo $magic | tr 'A-Z' 'a-z'` in *packed*|*gzip*|*compress* ) ! DECOMPRESS="gzip -dc" ! magic=$($DECOMPRESS - | file -) ! magic=${magic#*: } ! ;; * ) ! DECOMPRESS="" ! ;; esac $FPIDIR/rewindstdin ! if [ "$DEBUG_FILTER" != "" ]; then echo "Magic is |$magic|" >> /tmp/filter.debug fi
Boy, is MY face red! Here is the proper patch file for the generic PostScript print filter: ---------------------------------------------------------------------- *** filter Tue Sep 14 12:12:08 1999 --- filter.new Tue Sep 14 12:12:12 1999 *************** *** 166,196 **** # Figure out the magic of the input file # magic=$(file -) - $FPIDIR/rewindstdin magic=${magic#*: } ! if [ "$DEBUG_FILTER" != "" ]; then ! echo "Magic is |$magic|" >> /tmp/filter.debug ! fi case `echo $magic | tr 'A-Z' 'a-z'` in *packed*|*gzip*|*compress* ) ! DECOMPRESS="gzip -dc";; * ) ! DECOMPRESS="";; esac - # - # Figure out the magic of the input file - # - if [ "$DECOMPRESS" = "" ]; then - magic=$(file -) - else - magic=$($DECOMPRESS - | file -) - fi $FPIDIR/rewindstdin ! magic=${magic#*: } if [ "$DEBUG_FILTER" != "" ]; then echo "Magic is |$magic|" >> /tmp/filter.debug fi case `echo $magic | tr 'A-Z' 'a-z'` in *empty* ) exit;; --- 166,191 ---- # Figure out the magic of the input file # magic=$(file -) magic=${magic#*: } ! case `echo $magic | tr 'A-Z' 'a-z'` in *packed*|*gzip*|*compress* ) ! $FPIDIR/rewindstdin ! DECOMPRESS="gzip -dc" ! magic=$($DECOMPRESS - | file -) ! magic=${magic#*: } ! ;; * ) ! DECOMPRESS="" ! ;; esac $FPIDIR/rewindstdin ! if [ "$DEBUG_FILTER" != "" ]; then echo "Magic is |$magic|" >> /tmp/filter.debug fi + case `echo $magic | tr 'A-Z' 'a-z'` in *empty* ) exit;;
Thanks for the patch... Looking into it now.
Thanks, it's in CVS now.
Are you sure it's really broken? When I turn on DEBUG_FILTER and DEBUG_TREE in the filter file & use lpr to print things, it seems to work fine. However, I almost sent the same bug report because rewindstdin works on redirections but *not* on pipes. So, when I tried to test the filter script by "cat file | filter >output" it wouldn't work - the 2nd invocation of file inside of the filter script would just return "data". However, when I tested it by "filter file >output", it worked fine. It seems that it's invoked by lpr in the latter fashion, and thus is ok. Of course, your patch is certainly cleaner than the original, so it should stay, but I don't think it has anything to do with rewindstdin being broken.