0

在 wget 中,我尝试使用以下 Wget 命令从 FTP 服务器获取文件列表及其属性,

wget --no-remove-listing ftp://myftpserver/ftpdirectory/

这将生成两个文件:.listing(这是我在 cURL 中查看的内容)和 index.html,它是列表文件的 html 版本。

我的期望: 在 cURL 中如何实现这个场景?使用 CURL从 FTP/SFTP 服务器获取 .listing 和 index.html 文件的命令是什么。

4

2 回答 2

3

This is what I found on http://curl.haxx.se/docs/faq.html#How_do_I_get_an_FTP_directory_li

If you end the FTP URL you request with a slash, libcurl will provide you with a directory listing of that given directory. You can also set CURLOPT_CUSTOMREQUEST to alter what exact listing command libcurl would use to list the files.

The follow-up question that tend to follow the previous one, is how a program is supposed to parse the directory listing. How does it know what's a file and what's a dir and what's a symlink etc. The harsh reality is that FTP provides no such fine and easy-to-parse output. The output format FTP servers respond to LIST commands are entirely at the server's own liking and the NLST output doesn't reveal any types and in many cases don't even include all the directory entries. Also, both LIST and NLST tend to hide unix-style hidden files (those that start with a dot) by default so you need to do "LIST -a" or similar to see them.

Thanks & Regards,
Alok

于 2013-09-12T13:25:45.620 回答
0

我已经在 WIN->CygWin 上检查了它,它对我有用:

不要忘记/在路径的尽头使用。

$ curl -s -l -u test1@test.com:Test_PASSWD --ftp-ssl 'ftps://ftp.test.com/Ent/'
于 2017-06-27T12:42:56.010 回答