FTP脚本放置后保留文件的时间戳 [英] FTP script retain timestamp of a file after put
问题描述
我知道FTP不支持传输和保留文件日期/时间戳 想知道是否有人在放置操作后有任何想法/脚本(Shell/perl)可以保留传输文件的时间戳?
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?
推荐答案
-
一个选项是
rcp -p
.我敢肯定,还有一些等效项可以用于更安全的scp
.
One option is
rcp -p
. I'm sure some equivalent exists for more securescp
as well.
如Autocracy所述,如果可以的话,只需tar/zip/否则将文件存档,然后再传输并还原.不幸的是,这并不总是有效-请说您是否无法控制/访问文件的源服务器.
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.
或者,通过FTP对文件进行获取"设置后,使用Perl的utime()
或Unix的touch
命令将时间戳更改为正确的时间戳.
Alternately, after "get"-ting the file via FTP, change timestamp to the correct one using Perl's utime()
or Unix's touch
command.
需要注意的是,如果您要将文件放到远程服务器上,则需要连接(ssh/telnet/rsh)来运行touch命令.有点麻烦,不是我所建议的,但即使是放置"也是一种有效的解决方案.
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".
这篇关于FTP脚本放置后保留文件的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!