Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to compare the modified date of a local file and the equivalent file on a remote FTP site (via FTP, no SSH access). I'm using Python's ftplib btw. The only way I can find to get the remote modified date is by using the dir command, but that doesn't output the year. Using gFTP shows the year in the modified date, so there must be a way of getting that information. Any ideas?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

If your FTP server supports it, you could try using the MDTM command. This returns the file modification time in the format YYYYMMDDHHMMSS.sss. The milliseconds are optional and the time is in GMT.

It doesn't look like ftplib supports MDTM directly, but you should be able to call it with sendcmd:

ftp.sendcmd('MDTM filename')
share|improve this answer
    
Excellent! That was exactly what I was looking for. Thanks very much. –  Skilldrick Jan 30 '10 at 14:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.