First off, I assume you're on a *nix machine. But figured I should state that in advance.

One problem you are facing is the file comes into existence, but isn't quite all there yet. I've seen this handled two ways 1) create the payload file in another location and then use a local system move to put it in the monitor directory and 2) move the payload file then move a trigger file (zero byte file) to the monitor directory.

Neither of these techniques are perfect, but they might be good enough™

Another option might be to use something like dnotify or it's ilk to tell you when the file has arrived. Although these will depend on your os.

I've tried to use an os dependent directory monitor, however, I ran into problems when the monitor directory went from a local disk to an NFS mount. That's a much harder problem to solve.

Just some thoughts

Hazah! I'm Employed!


In reply to Re: select, stat, and waiting for files by osunderdog
in thread select, stat, and waiting for files by oakbox

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.