Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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 "test test" $ logger -p "test test" $ logger -p "test test" $ logger -p "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 #!/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 ./ 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 ?

In reply to Understanding FIFO pipes and Syslog by Plankton

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (3)
    As of 2018-11-14 05:14 GMT
    Find Nodes?
      Voting Booth?
      My code is most likely broken because:

      Results (163 votes). Check out past polls.