1

In python,

from ftplib import FTP
ftp = FTP("speedtest.tele2.net")
ftp.login("anonymous", "abc@gmail.com")
ftp.cwd("/upload")
ftp.retrlines('LIST')

Above code gives output like below:

-rw-------    1 105      108      34731200   Oct 05 17:50 100MB.zip
-rw-------    1 105      108      17404256   Oct 05 17:44 1_7708308143086291200_17-9ULspeedtest.upt
-rw-------    1 105      108       3889879   Oct 05 17:48 1_890431022834275069_17-9ULspeedtest.upt
-rw-------    1 105      108      8239537808 Oct 05 17:50 Die.glorreichen.Sieben.2016.German.1080p.DL.DTSHD.BluRay.AVC.Remux-pmHD.mkv
-rw-------    1 105      108        277504   Oct 05 17:50 _verizon_Quectel_COM57_512KB.zip

I am interested to get the last-modified-time of a file in epoch milliseconds. How to get it ?

cyrilantony
  • 274
  • 3
  • 14
  • Does your edit to the question title mean that you are not satisfied with my answer to the duplicate question? - My answer summarizes **all the options** you have to retrieve timestamp using FTP protocol. If none of the options listed there give you milliseconds, you are out of luck. – Martin Prikryl Oct 10 '18 at 09:11

1 Answers1

1

The FTP protocol does not standardize the output format of the LIST command. What you see is all what you get. You could try LIST --full-time and see if you get ISO output with microseconds, but this is a bit of a stretch. it does not appear to work with the server in question.

The server supports the MDTM command, so you can at least get the modification time in seconds this way, but apparently it does not work in the /upload directory; it may need read access on the files for some reason. Access to millisecond information does not seem to be supported.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92