Operating System - HP-UX
1752299 Members
5146 Online
108786 Solutions
New Discussion юеВ

Redirect serial output to file

 
Mike Keys
Regular Advisor

Redirect serial output to file

We have a serial attached printer that prints real-time charges from a system in our hospital. There is no functionality to redirect this print stream to a file within the application. Is there any way at the OS level to redirect the serial data stream so that it will print to a file rather than the printer?

Feel free to move this post if not in the appropriate category.
7 REPLIES 7
TTr
Honored Contributor

Re: Redirect serial output to file

You can probably hack /etc/lp/interface script and redirect all lines that produce output to a file.

You should probably create a new spooler pointing to a local serial port and then hack the interface script. There are two sections that you need to change, first the section that creates the header page, and second the section that prints the file at the bottom. Add output redirects to every echo, banner, date cat statement in that section.

What do you intend to do with the file output of your printouts? And would you go back and forth between printer and file?
Mike Keys
Regular Advisor

Re: Redirect serial output to file

Nope the goal is to eliminate the serial printer all together. The application doesn't have anything built in to redirect the stream (real-time) to a file. The stream contains charges and the printout is how we reconcile chrages in the event of a discrepancy or system crash whereby we would have to enter charges not posted since the last backup.
Steven Schweda
Honored Contributor

Re: Redirect serial output to file

> [...] Is there any way [...]

It may depend on exactly how the application
deals with the serial port. I gather that
you're not queuing print jobs, rather, the
app is opening some (Which?) serial port
device somehow (How?) and talking directly to
that serial port device (and hence the
printer itself).

If the app only sends data to the printer,
and doesn't try to read any data back from
the printer, then you might be able to do
something simple, like specify a file instead
of the serial port device name. Or, if the
port device name is fixed, rip out the actual
device, and replace it with a link to plain
file (somewhere outside of /dev).

As usual, everything's complicated, and with
no info on how the app does what it does,
it's hard to say how to make it do something
else.
TTr
Honored Contributor

Re: Redirect serial output to file

So does the app print directly to the serial port bypassing the LP spooling system or does it use a UNIX spooler that prints to the serial port connected printer?
Mike Keys
Regular Advisor

Re: Redirect serial output to file

It doesn't use a unix spooler. I'm trying to find out exactly how this works from the application vendor. I'll post when I know.
Dennis Handly
Acclaimed Contributor

Re: Redirect serial output to file

>I'm trying to find out exactly how this works from the application vendor.

You could also use tusc to trace the system calls.
Mark Grant
Honored Contributor

Re: Redirect serial output to file

If the application doesn't use the Unix spooler the only options it has that I can think of is to directly open the serial port itself and start squirting data at it. Seems dumb to me but if it is so, it's unlikely that your application will continue to print if you remove the printer.

In any case, have you just tried to "cat" the serial port and re-direct the output ?
Never preceed any demonstration with anything more predictive than "watch this"