0

I have a python script which downloads files from FTP. I am using ftplib for this and downloading using following statement.

ftp.retrbinary('RETR ' + file, open(path, 'wb').write)

Now the problem is, On the FTP, Someone opened an xslx file in their program and opened in write mode. When I execute my python script I am getting that xlsx file with the contents that were saved to disk on the FTP.

I am curious to know if I can alert with "File is in Write Mode or Locked on FTP".

techrhl
  • 434
  • 8
  • 19
  • 2
    As I know FTP has no function for this. Maybe with SSH you could have access to processes and other information. I'm not sure but If someone used Excel to open it then it may create file with similar filename but with `~` - and this can be method to detect if file is open. – furas Aug 02 '21 at 10:13
  • I agree but that does not sound graceful to me. – techrhl Aug 02 '21 at 10:46
  • 1
    `FTP` was created only for `File Transfer` and it doesn't have other functions. – furas Aug 02 '21 at 10:56
  • Make sense to me. – techrhl Aug 02 '21 at 11:46

0 Answers0