[comp.unix.i386] Logging console messages to a printer.

jgd@rsiatl.UUCP (John G. De Armond) (01/02/90)

This may be a RTFM question, in which case, a pointer to the correct
FM would be appreciated.  

System:  ISC 2.0.2

How do I redirect console messages to a printer to be dedicated for
that purpose?  I want to log everything that goes to the console and yet
not loose keyboard control of the console for shutting the system down.
(I've seen the patches to init and shutdown; I want a bit more elegant
solution if possible.)  The printer is an ordinary epson matrix unit sitting
on /dev/lp0.  No other jobs are anticipated for that printer.

Thanks in advance,
John

-- 
John De Armond, WD4OQC                     | The Fano Factor - 
Radiation Systems, Inc.     Atlanta, GA    | Where Theory meets Reality.
emory!rsiatl!jgd          **I am the NRA** | 

mark@zok.UUCP (Mark W. Snitily) (01/05/90)

In article <1016@rsiatl.UUCP> jgd@rsiatl.UUCP (John G. De Armond) writes:
>This may be a RTFM question, in which case, a pointer to the correct
>FM would be appreciated.  
>
>System:  ISC 2.0.2
>
>How do I redirect console messages to a printer to be dedicated for
>that purpose?  I want to log everything that goes to the console and yet
>not loose keyboard control of the console for shutting the system down.
>(I've seen the patches to init and shutdown; I want a bit more elegant
>solution if possible.)  The printer is an ordinary epson matrix unit sitting
>on /dev/lp0.  No other jobs are anticipated for that printer.

   Haven't tried this, but I think that

      tail -f /dev/osm | /dev/lp0 &

should do the trick.  You'll need to have the read access to /dev/osm
and write access to /dev/lp0, of course.

   Device "osm" stands for "operating system messages".  You have to have
the driver built into the kernel.  In kconfig this is selected under
the  "ADD FACILITY" item.  The facility you want to add is "Operating
System Messages".  (If you already have added it, it won't show up under
ADD FACILITY but will be listed under REMOVE FACILITY.)

   Hope that helps.  Please let the net know if that works.

-- Mark

Mark W. Snitily                 Consulting Services:
894 Brookgrove Lane             Graphics, Operating Systems, Compilers
Cupertino, CA 95014             (408) 252-0456
mark@zok.uucp

jgd@rsiatl.UUCP (John G. De Armond) (01/05/90)

In article <399@zok.UUCP> mark@zok.UUCP (Mark W. Snitily) writes:
>In article <1016@rsiatl.UUCP> jgd@rsiatl.UUCP (John G. De Armond) writes:
>>
>>How do I redirect console messages to a printer to be dedicated for
>>that purpose?  
>
>   Haven't tried this, but I think that
>
>      tail -f /dev/osm | /dev/lp0 &
>
>should do the trick.  You'll need to have the read access to /dev/osm
>and write access to /dev/lp0, of course.

I appreciate everybody that has suggested the OSM facility.

I should not have neglected to mention in my first post that I had figured
out how to use /dev/osm for kernal messages.  What I'm wanting to do is more
general.  I want to send everything that currently goes to /dev/console
to a logging printer just as if /dev/console were a KSR terminal.  At the
same time, I'd like to STOP the printing of messages to the real /dev/console.
I guess one solution WOULD be to just hang a KSR terminal (Decwriter, anyone?)
on a port and re-mknod /dev/console to that port.  I was hoping there is an
undocumented (of course), but elegant way of solving this problem.  I'm 
working on an inelegant solution (the one true unix way) but I'd hoped
for more.

Thanks again for everyone who has suggested /dev/osm.

John

-- 
John De Armond, WD4OQC                     | The Fano Factor - 
Radiation Systems, Inc.     Atlanta, GA    | Where Theory meets Reality.
emory!rsiatl!jgd          **I am the NRA** | 

bill@twwells.com (T. William Wells) (01/05/90)

In article <1052@rsiatl.UUCP> jgd@rsiatl.UUCP (John G. De Armond) writes:
: I should not have neglected to mention in my first post that I had figured
: out how to use /dev/osm for kernal messages.  What I'm wanting to do is more
: general.  I want to send everything that currently goes to /dev/console
: to a logging printer just as if /dev/console were a KSR terminal.  At the
: same time, I'd like to STOP the printing of messages to the real /dev/console.
: I guess one solution WOULD be to just hang a KSR terminal (Decwriter, anyone?)
: on a port and re-mknod /dev/console to that port.  I was hoping there is an
: undocumented (of course), but elegant way of solving this problem.  I'm
: working on an inelegant solution (the one true unix way) but I'd hoped
: for more.

How about:

	(setup)

	mv /dev/console /dev/realcons
	mknod /dev/console p
	chmod 622 /dev/console

	(to actually use this:)

	dd bs=1 if=/dev/console of=/dev/lp >/dev/null 2>&1 &

Why dd? Because cp buffers its I/O. Of course, you could put
anything on the other end of the pipe.

Oh yes, if I read the manual correctly, you have to have something
holding /dev/console open for write or the dd will get EOF. You might
make the last command

	dd bs=1 if=/dev/console of=/dev/lp >/dev/null 2>&1 3>/dev/console &

instead.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill@twwells.com