Jason Gerfen wrote:
> Bowie Bailey wrote:
> > Jason Gerfen wrote:
> > > I am looking to do something which I am not sure perl can do.  I
> > > would like to be able to issue a system command ex. tail -f /file
> > > and loop over that command while sorting the output.  Is this
> > > possible?  And if so could I see an example? 
> > 
> >    open(LOG, "tail -f /var/log/messages |");
> >    while (<LOG>) {
> >        if (/something important/) {
> >            print "Found something...\n";
> >        }
> >    }
> >    close LOG; # Never get here, but for completeness...
> > 
> > I'm not sure what you mean by sorting the output.  Since there is
> > continuous input, there will be continuous output.  You could sort
> > and display aggregated output at intervals rather than having a
> > real-time output stream.
> 
> Really?  So constantly piping the results of a log file through a
> function to sort the data is not the best method of giving real time
> data based on the piped output of a log file?

Sure, it just depends on exactly what you mean by "Sort the data".  What
kind of output are you looking for?

I have a few programs that do this exact thing.  They tail the log file
and page or email me when they find something.  The only problem I have
had is that it seems like the pipe will eventually break if you leave it
running for long enough.

-- 
Bowie
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to