I'm writing a program which has to work with what I now believe is a broken interface. It's purpose is to process data files after they've been ftp'd into a specific directory - my program will probably be invoked via cron, so sometimes there won't be any data to process - no problem.

After the data file is written via ftp, a control file is also written via ftp - it's the existance of this control file that tells my program that it's safe to proceed.

Now, this is where the fun starts - if my program hasn't processed the data file before the machine which originally sent it has more data to send, the other machine sends the original data, plus the new data, as one data file, overwriting the original data file, then updates the control file accordingly.

I move the data file to a work directory before processing it. If I use the File::Copy::move subroutine, what will happen if I try and move the file while it's being overwritten by the other machine?

I can't now change the way the remote machine behaves, and I don't know in advance what the ftp server is going to be on the box my program is to run on (although I do know that the OS is Solaris).

Does anyone have any advice on how I can make my program work safely?

Thanks.

Pete


In reply to When is it safe to move a file? by BoredByPolitics

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.