[syslog-ng]Using a perl script with the pipe destination driver
Loic Minier
syslog-ng@lists.balabit.hu
Wed, 28 Apr 2004 10:00:07 +0200
Jim Mozley <jim.mozley@exponential-e.com> - Tue, Apr 27, 2004:
> my @lines = <PIPE>;
> for ( @lines ) {
> # do some stuff
> }
This causes reading until the End Of File of PIPE, then you process all
lines.
Instead, I suggest you try:
while ( <PIPE> ) {
# do some stuff
}
[ Syslog-NG opens a pipe to your program when it is started and closes
it when it's stopped. It doesn't open a new pipe for each log line. ]
> cat syslog > pipe
When cat finishes, it causes an EOF in the pipe (no program has the
"pipe" file open for writing, so no more messages will come in), and
your program starts processing. You should notice with a large syslog
and a slow perl program that your processing starts when the cat
finishes.
--
Loïc Minier <lool@dooz.org>