简体   繁体   中英

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 --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.

My expectation: In cURL how to achieve this scenario? What is the command to get the .listing and index.html file from FTP/SFTP server using CURL .

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

I have checked it on WIN->CygWin and it works for me: Do not forget to use '/' at the end of the path.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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