HOW-TO watch log files with perl/EV for a fixed amount of time (timeout)?

Lars Holowko Lars.Holowko at quantum.com
Fri May 21 01:54:05 CEST 2010


Hi everybody,

 

I just stumbled over EV. What I am trying to accomplish is this:

 

Monitor and process a couple of log files (and react on keywords) with a
timeout.

 

I was trying to get things working with something down the line of

 

my $fn = "tail -f /var/log/messages";

open my $fh, '-|', $fn or croak "Can't open $fn: $::OS_ERROR";

 

my $watcher = EV::io $fh, EV::READ, sub {

      my ($watcher, $revents) = @_;

      warn "yeah, /var/log/messages should now be readable without
blocking!\n";

      my $fh = $watcher->fh;

      print <$fh>;

      warn "HUH\n";

};

 

my $timeout = EV::timer 20, 0, sub {

      warn "DONE after 20 secs\n";

      

      EV::unloop;

};

 

 

But that didn't work.

 

 

Any hint would be highly appreciated.

 

 

Thanks,

 

Lars

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20100520/e77e69db/attachment.html>


More information about the libev mailing list