I have a remote process that takes between 10 and 30 seconds to complete. This process creates a 1 to 3 meg file and then scp's that file to my server. The process on my server knows where that scp'd file will show up, but needs to wait until it is completed before sending it on to the user.

Let's assume that the remote process is doing it's thing, and that I am now, sitting on my server, waiting for the result file.

my $sanity; while(1){ if(-e $pdffile){ last; } sleep 1; $sanity++; if($sanity > 60){ return(0); } }
When I get through that chunk, I know the file exists. Yeah! Now I need to wait for it to stop growing...
while(1){ select(undef, undef, undef, 0.5); # .5 second wait my $usizer = (stat($pdffile))[7]; # how big is that file? if($usizer eq $sizer){ last; } # did it grow at all? $sizer = $usizer; # set size for next round }
Now for the question: Is this the *right* way to do this? Another programmer mentioned that using select/stat isn't reliable due to disk buffering/ network concerns.

- Thank you,
Richard


In reply to 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.