Jason Gerfen wrote: > Bowie Bailey wrote: > > 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. > > > > 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. > > Well I am 'attempting' to write a simple perl daemon that will listen > or 'tail -f /var/log/messages' for any iptables log which matches a > 'DROP'ed packet.
That's simple enough. Just follow my code above. > Upon seeing a matching condition it will fork a new process and then > begin sorting the data and send me alerts etc. Fork a new process? Why? It sounds like you just want to watch for DROPs and send alerts. Why the complication? > Does that help explain it a bit more? I can include code if > needed. Code might help. Some sample output would help more. What exactly are you expecting this program to send you? -- Bowie _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs