FTP脚本放置后保留文件的时间戳 [英] FTP script retain timestamp of a file after put

查看:344
本文介绍了FTP脚本放置后保留文件的时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道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?

推荐答案

  1. 一个选项是rcp -p.我敢肯定,还有一些等效项可以用于更安全的scp.

  1. One option is rcp -p. I'm sure some equivalent exists for more secure scp 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆