[CLUE-Tech] Partial file troubles

Dave Anselmi anselmi at americanisp.net
Wed Jan 9 11:13:01 MST 2002


Grant Johnson wrote:

[...]

> Here is the problem:
> The file is marked as modified, or comes into existence before the FTP
> is complete.  PGP does not like this.  Is there a test for the number of
> open file handles on that inode, or a way to tell if exclusive access is
> available to a file so that we can tell from the shell script when FTP
> is done before we start the PGP?

lsof may be what you need.  See lsof(8).

Perhaps you could also change your scripts so the trigger condition is
atomic.  For example, you could ftp the file to a temporary name and then
rename it.  Renaming is atomic while the transfer is not.

I don't know if your ftp supports renaming remote files, so here are some
other ideas:

Use a directory as the trigger since ftp does have a mkdir.

Ftp a lock file over.  While the lock file exists, the script won't run even
though the data file has been modified.  After the data file ftp is
complete, remove the lock file.  Since this is more complicated, perhaps it
is more subject to breakage.  On the other hand, you'll know that the ftp
didn't end prematurely.  Depends what you need.

Dave





More information about the clue-tech mailing list