下载与卷曲的目录中的所有文件 [英] downloading all the files in a directory with cURL
问题描述
我使用cURL来尝试下载某个目录中的所有文件。
I am using cURL to try to download all files in a certain directory.
这里就是我的文件列表如下:
here's what my list of files looks like:
我曾尝试在bash脚本做: iiumlabs [] csv.pgp
和 iiumlabs *
和我想袅袅不上通配符大了。
I have tried to do in bash script: iiumlabs.[].csv.pgp
and iiumlabs*
and I guess curl is not big on wildcards.
curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
的问题:怎样下载使用cURL文件的这个目录
question: how do i download this directory of files using cURL?
推荐答案
确定,考虑到你使用的是Windows,最简单的方法就是使用标准的 FTP
工具捆绑在一起的。我基地在Windows XP下的解决方案,希望它会在其他版本的工作,以及(或稍作修改)。
OK, considering that you are using Windows, the most simple way to do that is to use the standard ftp
tool bundled with it. I base the following solution on Windows XP, hoping it'll work as well (or with minor modifications) on other versions.
首先,您需要创建为 FTP
程序的批处理(脚本)文件,其中包含的说明。它命名为你想要的,并把它付诸表决:
First of all, you need to create a batch (script) file for the ftp
program, containing instructions for it. Name it as you want, and put into it:
curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
open ftp.myftpsite.com
login
pass
mget *
quit
第一行开放时间为 ftp.myftpsite.com
到ftp服务器的连接。下面的两个行指定的登录,密码支持FTP协议将要求(更换登录
和通过
只用登录名和密码,没有任何关键字)。然后,使用 MGET *
来获取所有文件。取而代之的是的 *
,你可以使用任何通配符。最后,使用退出
来关闭 FTP
程序,而不交互提示。
The first line opens a connection to the ftp server at ftp.myftpsite.com
. The two following lines specify the login, and the password which ftp will ask for (replace login
and pass
with just the login and password, without any keywords). Then, you use mget *
to get all files. Instead of the *
, you can use any wildcard. Finally, you use quit
to close the ftp
program without interactive prompt.
如果您需要先进入某个目录,在此之前 MGET
添加 CD
命令。它应该是pretty简单。
If you needed to enter some directory first, add a cd
command before mget
. It should be pretty straightforward.
最后,编写文件并运行 FTP
是这样的:
Finally, write that file and run ftp
like this:
ftp -i -s:yourscript
其中, -i
禁用交互(下载文件前询问)和 -s
指定的脚本,你的路径创建。
where -i
disables interactivity (asking before downloading files), and -s
specifies path to the script you created.
可惜的是,通过SSH文件传输本身不支持在Windows中。但是,对于这种情况下,你可能要使用腻子工具反正。对于这种情况特别感兴趣的人会 PSCP
这实际上是OpenSSH的的腻子反一部分 SCP
命令
Sadly, file transfer over SSH is not natively supported in Windows. But for that case, you'd probably want to use PuTTy tools anyway. The one of particular interest for this case would be pscp
which is practically the PuTTy counter-part of the openssh scp
command.
的语法类似于复制
命令,并支持通配符:
The syntax is similar to copy
command, and it supports wildcards:
pscp -batch login@mysshsite.com:iiumlabs* .
如果您使用认证密钥文件,你应该使用它传递 -i路径到密钥文件
。如果您使用的密码, -pw通
。它也可以重用PuTTY的使用保存的会话,使用负载 -load您的会话名称
参数。
If you authenticate using a key file, you should pass it using -i path-to-key-file
. If you use password, -pw pass
. It can also reuse sessions saved using PuTTy, using the load -load your-session-name
argument.
这篇关于下载与卷曲的目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!