*BSD News Article 74122


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!gatech!news.mathworks.com!news.kei.com!nntp.coast.net!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!awfulhak.demon.co.uk!not-for-mail
From: brian@awfulhak.demon.co.uk (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Printer filter file error
Date: 18 Jul 1996 17:37:50 +0100
Organization: Coverform Ltd.
Lines: 84
Message-ID: <4slp8u$hd@anorak.coverform.lan>
References: <4sd8g1$ruk@slowmo.techfak.uni-kiel.de> <31EB1D42.493B@www.play-hookey.com>
NNTP-Posting-Host: localhost.coverform.lan
X-NNTP-Posting-Host: awfulhak.demon.co.uk
X-Newsreader: TIN [version 1.2 PL2]

Ken Bigelow (kbigelow@www.play-hookey.com) wrote:
: Read the source (STDIN for the filter) one character at a time. If the 
: character is LF, send CR to the printer (STDOUT). In any case, then send 
: the character itself to STDOUT.

: This filter is real simple in C or any language that can read the input 
: stream by characters, and won't skip any.

Even simpler in sed:

    sed 's/$/^M/'

(the ^M is an actual CTRL-M - got by typing CTRL-V followed by CTRL-M).

So what about my problem.  My filter script says:

	sed 's,$,^M,' $TmpFile >/tmp/LastPrint
	cat /tmp/LastPrint

/tmp/LastPrint is correct, but the printer output is minus the first
line, and gets truncated - at 1460 bytes (including the first line).

I've modified the lpd code in two places (diffs at the bottom of this
message) to allow printing across the network via a filter.  Still,
the code just attaches the tcp file descriptor to stdout on the output
filter - so what could be going wrong ?

I'm not sending *any* printer init strings.  I've seen what appears
to be a similar problem with doing a "telnet .... <<eof" command.  It
seems that when the EOF is read by the shell (bash/ash), it drops
the tcp connection - even though the stuff before the eof isn't
sent:

telnet localhost 3000 <<eof
set timeout 30
eof

Does nothing.  If I insert 10000 linefeeds between the second and
third lines, it works......

Any suggestions ?  TIA.

My (unobtrusive) lpd diffs are:

*** usr.sbin/lpr/lpd/printjob.c	Thu May  9 11:29:56 1996
--- usr.sbin/lpr/lpd/printjob.c.orig	Sat Sep  2 18:53:14 1995
***************
*** 215,221 ****
  		i = strlen(line);
  		if (write(lfd, line, i) != i)
  			syslog(LOG_ERR, "%s: %s: %m", printer, LO);
! 		if (!remote || ofilter)
  			i = printit(q->q_name);
  		else
  			i = sendit(q->q_name);
--- 215,221 ----
  		i = strlen(line);
  		if (write(lfd, line, i) != i)
  			syslog(LOG_ERR, "%s: %s: %m", printer, LO);
! 		if (!remote)
  			i = printit(q->q_name);
  		else
  			i = sendit(q->q_name);
***************
*** 1259,1265 ****
  	/*
  	 * Start up an output filter, if needed.
  	 */
! 	if (OF) {
  		int p[2];
  		char *cp;
  
--- 1259,1265 ----
  	/*
  	 * Start up an output filter, if needed.
  	 */
! 	if (!remote && OF) {
  		int p[2];
  		char *cp;
  

--
Brian <brian@awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour....