From owner-freebsd-doc Fri Dec 29 15:41:01 1995 Return-Path: owner-doc Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id PAA23275 for doc-outgoing; Fri, 29 Dec 1995 15:41:01 -0800 (PST) Received: from parody.tecc.co.uk (parody.tecc.co.uk [193.128.6.83]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id PAA23262 for ; Fri, 29 Dec 1995 15:40:56 -0800 (PST) Received: (from james@localhost) by parody.tecc.co.uk (8.6.12/8.6.12) id OAA00366; Fri, 29 Dec 1995 14:37:15 GMT Date: Fri, 29 Dec 1995 14:37:13 +0000 () From: James Raynard To: doc@freebsd.org Subject: Handbook - printer setup Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-doc@freebsd.org Precedence: bulk I spent most of last night trying to set up a printer for the first time ever under Unix following the Handbook step-by-step. On the whole, it was quite a good set of instructions, but there were one or two points that may be worth picking up. Due to the staircase effect, the "Printer on a Parallel Port" test appeared to only produce one line of output on my DeskJet 520, which was a bit alarming until I realised what was happening. It does say "You should see something print. Don't worry if the text doesn't look right; we'll fix such things later"; perhaps this could be changed to "You should see something print. Don't worry if the text doesn't look right, or if it disappears at the end of the first line; we'll fix such things later."? The bit that really had me tearing my hair out was when I tried to use the suggested text filter - I kept getting errors 'execv of /usr/local/libexec/hpif failed'. After checking the paths and were correct, checking that the filter was world-readable and executable and successfully piping into and out of the filter by hand I was at a complete loss. I then noticed that the supplied /usr/libexec/lpf didn't have this problem. It did cross my mind that it could be a problem with something being setuid. However, the Handbook says that the text filter is run by lpd, which is not setuid or setgid on my system, so I assumed it was something else. As I had by now completely run out of ideas, I compiled a C program which did the same as hpif. This worked! So the only explanation I can think of is that it is a setuid problem and it's actually one of the other lp? programs which execv's the filter (sorry, I know nothing about how print spoolers work). Anyway, something needs changing in this part of the documentation. If it's any use, here's the C program I used:- #include #define LINELEN 255 #define INITSTR "\033&k2G" main() { char buf[LINELEN]; if (printf(INITSTR) == 0) exit(2); while (fgets(buf, LINELEN, stdin)) printf(buf); printf("\f"); return 0; } (Yes, this is the first time I've ever checked the return value from printf 8-) And here's the one I used for Ghostscript (I used different printer names for text and gs, so I didn't bother with the magic number test):- #include #define LINELEN 255 main() { char buf[LINELEN]; FILE *fp; if ((fp = popen("/usr/local/bin/gs -dSAFER -dNOPAUSE -q \ -sDEVICE=deskjet -sOutputFile=- -", "w")) == NULL) exit(2); while (fread(buf, 1, LINELEN, stdin) == LINELEN) if(fwrite(buf, 1, LINELEN, fp) != LINELEN) exit(2); pclose(fp); printf("\f"); return 0; } This had me tearing my hair out as well, due to a Ghostscript bug which I've reported to them (it was using an undocumented feature of the DeskJet500 that doesn't work on my DJ520), but that's another story! Cheers James Segmentation fault (core dumped): cannot find file '.signature'