views:

266

answers:

3

I know that FTP does not support transferring and retaining file date/time stamps Wondering if anyone has any ideas/scripts (Shell/perl) that would retain a transfered file's timestamp after a put operation?

+2  A: 

Can you perhaps attempt to transfer your files in a tar file? Upon extraction from the .tar, timestamps will be restored.

Autocracy
Good option but how can you untar via ftp command? For example, I only have ftp access to this server
ring bearer
"site" or "quote" commands may allow you to execute supported system commands. Unfortunately for you, this varies wildly by system. For example, I don't believe proftpd ever allows execution of system software (whereas other FTP systems may use 'ls' to provide ls functions), however it does provide the "SITE UTIME 200412312359 /path/to/some/file.txt" method of changing the timestamp.
Autocracy
+1  A: 
  1. One option is rcp -p. I'm sure some equivalent exists for more secure scp as well.

  2. As noted by Autocracy, if you can, just tar/zip/otherwise archive the file before transferring and revert back. Unfortunately this doesn't always work - say if you don't have control/acces to the file's source server.

  3. Alternately, after "get"-ting the file via FTP, change timestamp to the correct one using Perl's utime() or Unix's touch command.

    The caveat is if you're putting the file onto a remote server, you need to connect (ssh/telnet/rsh) to run the touch command. Kinda cumbersome and not what I'd recommend, but a valid solution even for "put".

DVK
The equivalent option for `scp` is `-p`
mobrule
+2  A: 

ncftp is the standard upgrade over /bin/ftp. Check out ncftpput's -yoption:

-y Try using "SITE UTIME" to preserve timestamps on remote host. Not many remote FTP servers support this, so it may not work.

You might also rest assured knowing ncftp works great on a ton of platforms (Windows included)

Evan Carroll