Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
May 19, 2005, 1:37 pm
rate this thread
I'm trying to write a perl process to continualy read from a log file,
line by line, and
commit the line to a database. The database part is easy. The problem
is reading from
the log file....
If I open the log file like this:
open(LOG, "/radius/radius.log") || die "Cannot open radius.log\n";
It process all the lines in the log file then exits, which is not what
I want, since there's
always new information comming into the log.
I have this in there now, which works but isn't the most elegant
open(LOG, "tail -f /radius/radius.log | ") || die "Cannot open
Anyone have any ideas how I can tell open that the file will continue
to grow forever and
it shouldn't exit (I thought the first open and while statement would
continue to read until
it got an EOF.
Even tried to be tricky and make the log file a named pipe, since I
don't really want the file hanging around, but the program was "smart"
enough to notice and not like it.
Re: Continuous reading from a log file (ie: tail -f)
How about File::Tail on CPAN?
codito, ergo sum.