FTP script retain timestamp of a file after put

天涯浪子 提交于 2019-12-24 05:40:08

问题


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?


回答1:


  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".




回答2:


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




回答3:


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)



来源:https://stackoverflow.com/questions/2960719/ftp-script-retain-timestamp-of-a-file-after-put

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!