Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Understanding FIFO pipes and Syslog

by Plankton (Priest)
on Oct 03, 2010 at 18:27 UTC ( #863196=perlquestion: print w/ replies, xml ) Need Help??
Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Dear Wise Monks,

I have been playing around with reading a FIFO that was created like so:

$ sudo mkfifo /var/log/blackhole.pipe
Then I modified my /etc/syslog.conf ...
$ cat /etc/syslog.conf ... # test logger script local1.* |/var/log/blackhole.pipe
... then restart syslogd. I can test like by executing ...
$ logger -p local1.info "test test" $ logger -p local1.info "test test" $ logger -p local1.info "test test" $ logger -p local1.info "test test2"
.. and ...
$ cat /var/log/blackhole.pipe Oct 3 11:16:09 localhost plankton: test test Oct 3 11:16:15 localhost last message repeated 2 times Oct 3 11:16:19 localhost plankton: test test2
... but when I run this scripts ...
$ cat process_blackhole.pl #!/usr/bin/perl -w use strict; $|=1; my $fifo_file = "/var/log/blackhole.pipe"; my $fifo_fh; open($fifo_fh, "+< $fifo_file") or die "The FIFO file \"$fifo_file\" i +s missing, and this program can't run without it.:$!"; # just keep reading from the fifo and processing the events we read while (<$fifo_fh>) { chomp; print "read from pipe [$_]\n"; } # should never really come down here ... close $fifo_fh; exit(0);
... I get this output ...
$ sudo ./process_blackhole.pl read from pipe [Oct 3 11:22:45 localhost plankton: test test] read from pipe [Oct 3 11:22:52 localhost plankton: test test2]
... The strange thing is I do not always get the last message repeated 4 times output consistently. Is there something else besides $|=1 and using the +< on my open call ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://863196]
Approved by biohisham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2016-06-26 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (327 votes). Check out past polls.