in reply to Re^3: Socket or not
in thread Socket or not

The IN & OUT shared directories looks a great idea

And I guess the OP might check for fully uploaded files by requiring an md5 checksum for each uploaded file like 'filename.ext.md5' then all he does it comparing the values before processing.

Replies are listed 'Best First'.
Re^5: Socket or not
by BrowserUk (Patriarch) on Nov 25, 2010 at 02:52 UTC

    Nice idea++ Though I think that calculating and re-calculating an MD5 until you get a match might be rather expensive.

    A cheaper alternative would be to append the length of the file: filename.ext.123456. That way, a simple -s of the file will tell if it has been fully transferred.

    That would make the monitoring script very simple. All that would be needed is something like:

    #! perl -slw use strict; my $sharePath = '...'; while( 1 ) { for( glob $sharePath . "IN/*" ) { my( $filename, $expected ) = m[/([^/]+)\.(\d+)$]; if( $expected == -s ) { rename $_, "$sharePath/$filename"; system 1, qq[theProcessingScript.pl <$sharePath/$filename >$sharePath/OUT/$file +name]; } } sleep 1; }

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.