Bug 65766

Summary: [printing] Fdescfs needs to be mounted on FreeBSD 5.x
Product: Documentation Reporter: Simon Barner <barner>
Component: Books & ArticlesAssignee: Marc Fonvieille <blackend>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Simon Barner 2004-04-19 16:30:19 UTC
The Handbook, Chapter 11, does not mention that you have to mount
fdescfs in order to use the example filter script (otherwise printing
does not work).

handbook/printing-advanced.html
 -> 11.4.1.3 Simulating PostScript on Non PostScript Printers

Fix: 

The following line in /etc/fstab

fdescfs /dev/fd fdescfs rw 0 0

and a mount /dev/fd made my printer work.

Furthermore I'd like to add that I had to remove the following line from
the ifhp example filter:

printf "\033&k2G" || exit 2
(I am using an Epson Stylus Color 740 via the stcolor driver, GNU
Ghostscript 7.07).
How-To-Repeat: 
Print w/o having that file system mounted. Enable logging in
/etc/printcap

:lf=/var/log/myprinter.log:

You will see the following error message:

Error: /invalidfileaccess in --.outputpage--
Operand stack:
   1   true
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-
-   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   fa
lse   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   
%oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringva
l--   --nostringval--   2   %stopped_push   --nostringval--   0   4   %oparray_p
op   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1059/1123(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--   --dict:10
6/300(L)--
Current allocation mode is local
Last OS error: 45
GNU Ghostscript 7.07: Unrecoverable error, exit code 1
Comment 1 Marc Fonvieille freebsd_committer freebsd_triage 2004-04-19 17:46:20 UTC
On Mon, Apr 19, 2004 at 05:23:41PM +0200, Simon Barner wrote:
> 
> >Fix:
> 
> The following line in /etc/fstab
> 
> fdescfs /dev/fd fdescfs rw 0 0
> 
> and a mount /dev/fd made my printer work.
>
[...]

Could you try this script:

#!/bin/sh

printf "\033&k2G" || exit 2

IFS="" read -r first_line
first_two_chars=`expr "$first_line" : '\(..\)'`

case "${first_two_chars}" in
\%\!*)
	/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \
	-sOutputFile=- - && exit 0
	;;
*)
	echo "$first_line" && cat && printf "\033&l0H" && exit 0
	;;
esac

exit 2

You will have to comment the 2nd line if you use an Epson printer (it's
your case) and don't forget to use the right device for -sDEVICE.

> Furthermore I'd like to add that I had to remove the following line from
> the ifhp example filter:
> 
> printf "\033&k2G" || exit 2
> (I am using an Epson Stylus Color 740 via the stcolor driver, GNU
> Ghostscript 7.07).

It's normal this line is for HP printers

Marc
Comment 2 Simon Barner 2004-04-19 18:42:51 UTC
Marc Fonvieille wrote:
> Could you try this script:

[...]

Thanks, that works nicely (without fdescfs).

> You will have to comment the 2nd line if you use an Epson printer (it's
> your case) and don't forget to use the right device for -sDEVICE.
> 
> > Furthermore I'd like to add that I had to remove the following line from
> > the ifhp example filter:
> > 
> > printf "\033&k2G" || exit 2
> > (I am using an Epson Stylus Color 740 via the stcolor driver, GNU
> > Ghostscript 7.07).
> 
> It's normal this line is for HP printers

Perhaps this could be mentioned in the handbook?

Simon
Comment 3 Simon Barner 2004-04-19 19:07:38 UTC
> #!/bin/sh
> 
> printf "\033&k2G" || exit 2
> 
> IFS="" read -r first_line
> first_two_chars=`expr "$first_line" : '\(..\)'`
> 
> case "${first_two_chars}" in
> \%\!*)
> 	/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \
> 	-sOutputFile=- - && exit 0
> 	;;
> *)
> 	echo "$first_line" && cat && printf "\033&l0H" && exit 0
> 	;;
> esac
> 
> exit 2


I just had another look at the original script:

    #
    #  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.
    #

Your script does not pay attention to the fact that postscript program
might mess up stdout, so I guess there is no way around the redirection
to fd 3.

Is there anything bad about having fdecsfs mounted?
Comment 4 Marc Fonvieille freebsd_committer freebsd_triage 2004-04-25 13:45:29 UTC
Responsible Changed
From-To: freebsd-doc->blackend

I'll take care of this one.
Comment 5 Marc Fonvieille freebsd_committer freebsd_triage 2004-06-21 13:21:41 UTC
State Changed
From-To: open->closed

I updated the Handbook example.  Thanks.