本文翻译自:How to recursively download a folder via FTP on Linux [closed]
我正在尝试使用命令行ftp client ftp文件夹,但到目前为止我只能使用'get'来获取单个文件。
#1楼
参考:https://stackoom.com/question/Tcs/如何在Linux上通过FTP递归下载文件夹-关闭
#2楼
If you can use scp
instead of ftp
, the -r
option will do this for you. 如果您可以使用scp
而不是ftp
, -r
选项将为您执行此操作。 I would check to see whether you can use a more modern file transfer mechanism than FTP. 我会检查你是否可以使用比FTP更现代的文件传输机制。
#3楼
You could rely on wget which usually handles ftp get properly (at least in my own experience). 你可以依赖通常处理ftp的wget得到正确的(至少在我自己的经验中)。 For example: 例如:
wget -r ftp://user:pass@server.com/
You can also use -m
which is suitable for mirroring. 您也可以使用适合镜像的-m
。 It is currently equivalent to -r -N -l inf
. 它目前相当于-r -N -l inf
。
If you've some special characters in the credential details, you can specify the --user
and --password
arguments to get it to work. 如果凭证详细信息中有一些特殊字符,则可以指定--user
和--password
参数以使其起作用。 Example with custom login with specific characters: 使用特定字符的自定义登录示例:
wget -r --user="user@login" --password="Pa$$wo|^D" ftp://server.com/
EDIT As pointed out by @asmaier, watch out that even if -r
is for recursion, it has a default max level of 5: 编辑正如@asmaier所指出的那样,注意即使-r
用于递归,它的默认最大级别为5:
-r --recursive Turn on recursive retrieving. -l depth --level=depth Specify recursion maximum depth level depth. The default maximum depth is 5.
If you don't want to miss out subdirs, better use the mirroring option, -m
: 如果您不想错过子目录,请更好地使用镜像选项-m
:
-m --mirror Turn on options suitable for mirroring. This option turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings. It is currently equivalent to -r -N -l inf --no-remove-listing.
#4楼
ncftp -u <user> -p <pass> <server>
ncftp> mget directory
#5楼
如果可以,我强烈建议您使用tar
和bzip
(或gzip
,无论你的船是什么漂浮)远程机器上的目录 - 对于任何大小的目录,带宽节省可能值得拉链/解压缩的时间。
#6楼
Use WGet instead. 请改用WGet。 It supports HTTP and FTP protocols. 它支持HTTP和FTP协议。
wget -r ftp://mydomain.com/mystuff
Good Luck! 祝好运!
reference: http://linux.about.com/od/commands/l/blcmdl1_wget.htm 参考: http : //linux.about.com/od/commands/l/blcmdl1_wget.htm