From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,d1c3ad67402116c7 X-Google-Attributes: gidf8c9b,public X-Google-Thread: fee84,d1c3ad67402116c7 X-Google-Attributes: gidfee84,public From: ken@halcyon.com (Ken Pizzini) Subject: Re: How to lock file from shell? Date: 1999/03/02 Message-ID: #1/1 X-Deja-AN: 450475157 References: <36DBBF44.BC07B1AD@ev.co.yu> Organization: _ User-Agent: slrn/0.9.5.3 (UNIX) Reply-To: ken@halcyon.com Newsgroups: comp.unix.questions,comp.unix.osf.osf1 On Tue, 02 Mar 1999 11:36:52 +0100, Nikola Milutinovic wrote: >Then I'll create one "pick-up" account. User with that USER/PASS will pick up >files. There will be a cron job, which will transfer files from "in-bound" >accounts to the "pick-up" account. > >Well, my problem is: how to detect that the file has been transferred? ... >The idea of testing a lock on the file, looked promissing, but I have to do it >from a shell script (zsh). "cp" doesn't care if the file is under a >lock/writing. I wouldn't want to implement any kind of "heuristic behavior" - >IF filesize unchanged for past 15 min THEN copy. 1. The best (IMO), if you have control over the client end, is to have the upload go to a tempfile, and then have the client do a REName of the tempfile to the final file name when the transfer has completed sucessfully. 2. The next most promising is the heuristic approach you rejected above. 3. You could check, either via ps or some special mechanism offered by your particular ftpd, to see that there are no ftp connections active. Special care must be used to avoid race conditions, probably by playing games with inter-directory intra-filesystem mv commands. Only suggestion (1) above is robust (with appropriate controls on the client end for determining that "the transfer has completed successfully") against the possibility that a client might loose their initial ftp connection and then later complete the file transfer. --Ken Pizzini