Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the FTP server list of directories? #906

Closed
fulvyou opened this issue Jul 7, 2016 · 3 comments
Closed

How to get the FTP server list of directories? #906

fulvyou opened this issue Jul 7, 2016 · 3 comments

Comments

@fulvyou
Copy link

fulvyou commented Jul 7, 2016

How to get the FTP server list of directories?help me, thank you!

curl/libcurl version 7.49.1

iOS

@jay
Copy link
Member

jay commented Jul 7, 2016

This is an issue tracker, for questions about curl or libcurl ask on the respective mailing list.

curl does not have a parser to get only the directories, you will have to parse them out. If your FTP server supports the standardized machine listing format (FTP command MLSD) you can look for type=dir; and the directory name is everything after the first space until the end of the line. If your FTP server does not support the machine listing format then I'm pretty sure you have to resort to LIST and work with whatever format you're given... for example the lines may start with permissions like drwxrwxr-x and end with the directory name which comes after a timestamp.

curl -s ftp.funet.fi/pub/ -X MLSD | perl -lne 'print if s/(?:^|;)type=dir;[^ ]+ (.*)$/$1/'
curl -s ftp.kernel.org/pub/linux/kernel/ | perl -lne 'print if s/^d[-rwx]{9}(?: +[^ ]+){7} (.*)$/$1/'

@jay jay closed this as completed Jul 7, 2016
@snikulov
Copy link
Member

snikulov commented Jul 7, 2016

@jay can be published in FAQ

jay added a commit that referenced this issue Jul 9, 2016
Explain how some FTP servers support the machine readable listing
format MLSD from RFC 3659 and compare it to LIST.

Ref: #906
@jay
Copy link
Member

jay commented Jul 9, 2016

@snikulov Good idea. Thanks, landed in f9eed59.

@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants