I received a question from a fellow free-os user (he's a bsd'er technically). Anyhow, he is trying to do something that I couldn't figure out how to handle. Granted, this isn't how I would try to perform the task at hand, but since it's not my call to make I just need to find a resolution. Is there a simple way to automatically print out each entry made to a log file to a simple line printer? Basically something that would work like "tail -f logfile > lpr" (which doesn't work BTW) sans page feeds on the printer. Granted, one could script something to read the last line of the logfile, store it in a variable, and then reread the file every minute or so printing out any changed lines and updating the variable. However, I figure someone somewhere must have had to do this already. Maybe? thanks! -- John LeMay KC2KTH Senior Enterprise Consultant NJMC | http://www.njmc.com | Phone 732-557-4848 Specializing in Microsoft and Unix based solutions
The 03.03.01 at 18:21, John LeMay wrote:
Is there a simple way to automatically print out each entry made to a log file to a simple line printer? Basically something that would work like "tail -f logfile > lpr" (which doesn't work BTW) sans page feeds on the printer.
[thinkink aloud] tailf logfile | somescript somescript while read LINE ; do echo "$LINE" >> anotherfile if wc -l anotherfile greater than 100 then lpr anotherfile and delete it done < stdin This is just an idea, and it doesn't work as is... perhaps you'd need to do it in C.
Granted, one could script something to read the last line of the logfile, store it in a variable, and then reread the file every minute
At least, the above does not reread the file.
or so printing out any changed lines and updating the variable. However, I figure someone somewhere must have had to do this already. Maybe?
I don't know... -- Cheers, Carlos Robinson
The 03.03.01 at 18:21, John LeMay wrote:
Is there a simple way to automatically print out each entry made to a log file to a simple line printer? Basically something that would work like "tail -f logfile > lpr" (which doesn't work BTW) sans page feeds on the printer.
man 5 syslog.conf [..] Named Pipes This version of syslogd(8) has support for logging output to named pipes (fifos). A fifo or named pipe can be used as a destination for log messages by prepending a pipe symbol (``|'') to the name of the file. This is handy for debugging. Note that the fifo must be created with the mkfifo(1) command before syslogd(8) is started. $ mkfifo /tmp/lpfifo /etc/syslog.conf: [..] *.warn |/tmp/lpfifo #End syslogd.conf # killall -HUP syslogd $ cat /tmp/lpfifo |lpr HTH, Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 27N , 4 29 45E. SuSE 8.0 x86 Kernel k_Athlon 2.4.19-4GB See headers for PGP/GPG info.
The 03.03.15 at 12:07, Theo v. Werkhoven wrote:
This version of syslogd(8) has support for logging output to named pipes (fifos). A fifo or named pipe can be used
I'll save this on my "interesting" mail box :-) -- Cheers, Carlos Robinson
participants (3)
-
Carlos E. R.
-
John LeMay
-
Theo v. Werkhoven