简体   繁体   English

使用cURL命令从SFTP服务器获取.listing文件的命令是什么

[英]What is the command to get the .listing file from SFTP server using cURL command

In wget I am trying to get the list of files and its properties from FTP server using below Wget command, 在wget中,我试图使用下面的Wget命令从FTP服务器获取文件列表及其属性,

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

This will generate two files: .listing (this is what I am looking in cURL) and index.html which is the html version of the listing file. 这将生成两个文件:.listing(这是我在cURL中看到的)和index.html,它是列表文件的html版本。

My expectation: In cURL how to achieve this scenario? 我的期望:在cURL中如何实现这种情况? What is the command to get the .listing and index.html file from FTP/SFTP server using CURL . 使用CURL从FTP / SFTP服务器获取.listing和index.html文件的命令是什么。

This is what I found on http://curl.haxx.se/docs/faq.html#How_do_I_get_an_FTP_directory_li 这是我在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. 如果您使用斜杠结束请求的FTP URL,libcurl将为您提供该给定目录的目录列表。 You can also set CURLOPT_CUSTOMREQUEST to alter what exact listing command libcurl would use to list the files. 您还可以设置CURLOPT_CUSTOMREQUEST以更改libcurl用于列出文件的确切列表命令。

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. 它是如何知道什么是文件,什么是dir以及什么是符号链接等等。严酷的现实是FTP没有提供如此精细且易于解析的输出。 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. FTP服务器响应LIST命令的输出格式完全由服务器自己喜欢,NLST输出不显示任何类型,在许多情况下甚至不包括所有目录条目。 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. 此外,默认情况下,LIST和NLST都会隐藏unix样式的隐藏文件(以点开头的文件),因此您需要执行“LIST -a”或类似操作才能看到它们。

Thanks & Regards, 感谢和问候,
Alok 阿洛克

I have checked it on WIN->CygWin and it works for me: Do not forget to use '/' at the end of the path. 我在WIN-> CygWin上检查了它,它适用于我:不要忘记在路径的末尾使用'/'。

$ curl -s -l -u test1@test.com:Test_PASSWD --ftp-ssl 'ftps://ftp.test.com/Ent/' $ curl -s -l -u test1@test.com:Test_PASSWD --ftp-ssl'ftps://ftp.test.com/Ent/'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM