[ILUG] Serial Port Logging
Niall O Broin
niall at linux.ie
Tue Sep 18 16:48:02 IST 2001
On Tue, Sep 18, 2001 at 03:56:37PM +0100, Adrian Flynn wrote:
> Can anyone suggest a suitable package to log traffic on a serial line. I
> wish to intercept data being sent to a serial printer and log it to a file.
> The data would then be retransmitted to the printer on a second serial port.
>
> I suspect that this might be as simple as a bash script copying from ttyS0
> to stdout, piping the output through tee and subsequently redirecting the
> output to ttyS1, but I am not sure how to set this up.
This is conceptually quite simple as long as the printer is using the
standard printcap system and not e.g. under the control of some printer
which is dumping data straight to a serial port. In the simplest case, you'd
just need to add a stanza like
:if=/usr/local/bin/lpcopier:
to the printcap entry for the printer where /usr/local/bin/lpcopier is simply
#!/bin/sh
/usr/bin/tee -a /var/log/printer_copy
However, with any current Linux distribution there'll already be an if line
using apsfilter or somesuch. On this SuSE 7.1 box, I have
:if=/var/lib/apsfilter/bin/y2prn_lp.upp--auto-lp:
and a first thought for that was simply to have /usr/local/bin/lpcopier as
#!/bin/sh
/usr/bin/tee -a /tmp/lpcopy | /var/lib/apsfilter/bin/y2prn_lp.upp--auto-lp
but that didn't work for me - the data was copied OK but not printed, so
some investigation of /var/lib/apsfilter/bin/y2prn_lp.upp--auto-lp would be
necessary - left as an exercise for the reader :-)
So, that's the general direction in which you've to go - shouldn't be too
hard.
Niall
More information about the ILUG
mailing list