CURL SFTP - 如何在下载时保留最后修改日期

发布于 2025-01-15 17:00:09 字数 384 浏览 3 评论 0原文

我正在尝试从另一台服务器下载文件,但我还需要获取文件的最后修改日期或最后时间戳。我使用curl sftp,这样我就不必每次运行它时都输入密码,并且我还将在perl 程序中运行curl 命令。

在 SFTP 中,我可以通过执行以下命令来保留它: get -p filename.txt

在我的curl 命令中,这就是我所做的:

curl -v -R -u user:userpass sftp://ip.add.re.ss:port/host/path/name/filename.txt > filename.txt 

但是每当我运行此命令时,时间戳总是会更新。

有人可以帮我下载该文件并保留上次修改的日期和时间吗?

I'm trying to download a file from another server but I also need to get the last modified date or the last timestamp of the file. I use curl sftp so that I don't have to enter my password every time I run it and I'm also going to run the curl command in perl program.

In SFTP I can preserve it by doing this command: get -p filename.txt

In my curl command, this is what I did:

curl -v -R -u user:userpass sftp://ip.add.re.ss:port/host/path/name/filename.txt > filename.txt 

But whenever I run this command, the timestamp is always updated.

Can someone help me to download the file and preserve the last modified date and time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞陪衬 2025-01-22 17:00:09

-R 不适用于 >

curl -R -o filename.txt -u user:userpass sftp://ip.add.re.ss:port/host/path/name/filename.txt

当您使用 > 时,它需要 -o 这并不是真正的curl命令,它是一个命令对于你的shell,它告诉你的shell将curl的输出保存到文件中,而你的shell不理解-R。但是-o告诉curl将输出保存到文件而不是打印文件,并且curl理解-R

-R doesn't work with > it requires -o

curl -R -o filename.txt -u user:userpass sftp://ip.add.re.ss:port/host/path/name/filename.txt

when you use > that's not really a command for curl, it's a command for your shell, it tells your shell to save curl's output to a file, and your shell doesn't understand -R. but -o tells curl to save the output to a file instead of printing the file, and curl understands -R

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文