FTP script retain timestamp of a file after put
I know that FTP开发者_如何学Go 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?
Can you perhaps attempt to transfer your files in a tar file? Upon extraction from the .tar, timestamps will be restored.
ncftp
is the standard upgrade over /bin/ftp
. Check out ncftpput
's -y
option:
-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)
One option is
rcp -p
. I'm sure some equivalent exists for more securescp
as well.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.
Alternately, after "get"-ting the file via FTP, change timestamp to the correct one using Perl's
utime()
or Unix'stouch
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".
精彩评论