A large data file is being pushed to us via FTP. We can assume that as
long as the file is open, the FTP transfer hasn't completed. How do we
test whether the file is still open? We know about fuser and lsof, but
we (my colleague, at least, who has to code the Perl) would prefer
using a purely Perlish approach. Is there a Perl module out there
somewhere that performs such a test?
I get the sense that, on the server side, you need to do something with
the file when the transfer is complete, right? If so, read on.
When the transfer is completed, you could send an empty file to the server
(like filename.extention.200). When the server goes about it's business,
and sees the file with the extention 200, it knows the file transfer is
completed and can remove the files with the 200 extention. I suggest
this because secure ftp sites won't allow you to remove files, just send
them (with good reason - you don't want someone to remove a file that was
just uploaded whenever they want

). This also aids in the issue of
the network connection being droped during transfer - because no file with
the 200 extention will be sent unless the transfer is completed. Worse
case is the file needs to be resent - which is something you will most
likely do anyway in the case of a network outage
I'm sure there's issues with this method I haven't thought of, but it
might fit the bill for what you're doing.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL.
http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
A lack of leadership is no substitute for inaction.