Continuous reading from a log file (ie: tail -f)

S

shawn

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";
while(<LOG>) {

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
solution.

open(LOG, "tail -f /radius/radius.log | ") || die "Cannot open
radius.log\n";
while(<LOG>) {

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.

thanks

Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top