Hi I am new to pearl and have been asked to create a perl script that executes a stats command on a program on our server.

The program on our server generates lines of stats every minute as follows(it runs indefinetly until you hit ctrl +c):

HH:MM:SS - 1,2,3

HH:MM:SS - 1,2,3

I want to runs this stats program so it always runs in the background and capture the output to a fifo. I then want read the last 30 lines(to give me the last 30 mins) in the fifo and write this to a actual file e.g. <timestamp>.csv (this file is then collected by a graphing program)

Can anyone suggesest the best way to do this. I have been googling and it seems like the best way is using forks and fifo's (which is all new to me)


In reply to Help with fork, read and write from a pipe by h123

Title:
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, details, 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, summary, 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.