in reply to Re: Re: FTP and File Copying
in thread FTP and File Copying

If you are running under a Unix OS, you can use a utility called "lsof" to determine what processes currently have the file open, and the mode used, etc. My lsof binary points to the URL ftp://vic.cc.purdue.edu/pub/tools/unix/lsof, if your system doesn't have it. The exit status of this program is 0 if any programs have the file open.

I really think this is kind of a crappy solution, though, because other programs may have that file open for other reasons that might not be easy to differentiate, and (as mentioned elsewhere), it doesn't help you if the FTP process legitimately closes the file in an incomplete form.

Replies are listed 'Best First'.
Re: Re: Re: Re: FTP and File Copying
by zigster (Hermit) on Nov 27, 2000 at 21:27 UTC
    Using lsof is not safe, ftp may release the file if the connection is broken an reaquire later this happens seamlessly from the users perspective. It is also not supported by all unix.

    The only 'safe' way to do this is to do what merlyn suggests. However if you cant rename then you could upload an empty file after the upload is complete and poll waiting for the control file to arrive, as soon as it arrives you know the preceeding download is complete.
    -- Zigster