如何在 Linux 上通过 FTP 递归下载文件夹 [英] How to recursively download a folder via FTP on Linux

查看:50
本文介绍了如何在 Linux 上通过 FTP 递归下载文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用命令行 ftp 客户端对文件夹进行 ftp,但到目前为止我只能使用get"来获取单个文件.

解决方案

您可以依赖 wget,它通常可以正确处理 ftp get(至少在我自己的经验中).例如:

wget -r ftp://user:pass@server.com/

您也可以使用适合镜像的-m.它目前等效于 -r -N -l inf.

如果凭据详细信息中有一些特殊字符,则可以指定 --user--password 参数以使其工作.带有特定字符的自定义登录示例:

wget -r --user="user@login";--password=Pa$$wo|^D"ftp://server.com/

正如@asmaier 所指出的,注意即使 -r 用于递归,它的默认最大级别为 5:

<块引用>

-r--递归打开递归检索.-l 深度--level=深度指定递归最大深度级别深度.默认最大深度为 5.

如果你不想错过子目录,最好使用镜像选项,-m:

<块引用>

-m- 镜子打开适合镜像的选项.此选项打开递归和时间戳,设置无限递归深度并保留 FTP 目录列表.目前等价于 -r -N -l inf--no-remove-listing.

I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files.

解决方案

You could rely on wget which usually handles ftp get properly (at least in my own experience). For example:

wget -r ftp://user:pass@server.com/

You can also use -m which is suitable for mirroring. It is currently equivalent to -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. Example with custom login with specific characters:

wget -r --user="user@login" --password="Pa$$wo|^D" ftp://server.com/

As pointed out by @asmaier, watch out that even if -r is for recursion, it has a default max level of 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
--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.

这篇关于如何在 Linux 上通过 FTP 递归下载文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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