I need some opinions / ideas here. I have a situation where a third party vendor is delivering files via ftp to one of our servers. They do not have the ability to do a 'rename' or any other ftp command outside of 'put'. We need to be able to tell when the file is complete and then move it to a processing directory.

A few methods have been used here before, but I don't really like them. They work fine, I'm just picky I guess.

One method was to watch the size over time. If the file didn't grow for X amount of time then consider it complete and begin processing. This has it's obvious flaws, just one of which being a slow network connection.

The other method was to perform and 'fuser -u' on the file and see if anything came back. Effective, but I prefer not to have to shell out of a perl script if I don't have to(I would like to keep this in perl).

Does anyone have a better way to see if a file is open or currently being written? It is possible to use Proc::ProcessTable, but that would be pretty ineffecient to run every 5 minutes (or sooner).

TIA,
Chad.


In reply to Detecting An Open File by gnu@perl

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.