Format of the data returned by the FTP LIST command?
Solution 1
The standard doesn't define format of the directory listing sent/received using LIST command. Most servers use Unix listing format (don't know if it's defined in any document, but it's rather simple to generate and parse), some use DOS/Windows format. Other formats (over 400 as far as I know) are used worldwide, but the Unix one has become a standard de-facto.
Now there's important thing to implement: MLST and LMSD extension commands, defined in RFC 3659. They define a way to produce and obtain machine-readable listing, which is very welcome in any modern FTP server.
Solution 2
This is what the RFC has to say:
The data transfer is over the data connection in type ASCII or type EBCDIC. (The user must ensure that the TYPE is appropriately ASCII or EBCDIC). Since the information on a file may vary widely from system to system, this information may be hard to use automatically in a program, but may be quite useful to a human user.
So, the result is not expected to be automatically parsed.
Solution 3
The RFC is poor there, but there are some nice links:
https://files.stairways.com/other/ftp-list-specs-info.txt
http://cr.yp.to/ftp/list/binls.html
Related videos on Youtube
Nathan Osman
Email: [email protected] By profession, I am a software developer and I work with C++, Python, and (more recently) Go. Here are some of my recent projects: - Hectane - lightweight SMTP server written in Go - NitroShare - a cross-platform network file transfer utility - REST Easy - Firefox add-on for analyzing HTTP responses
Updated on May 14, 2022Comments
-
Nathan Osman almost 2 years
I'm in the middle of writing an FTP server but I'm a little confused about what format to send the file list in.
Using 2 terminals and an FTP client, I was able to run through a simple FTP exchange. However, I wasn't really sure what format to send the file lists in.
Is there some accepted format? What columns should I use?
-
skaffman over 13 yearsI don't believe this is anything resembling a standard. Different servers give different outputs, they're supposed to be human-readable rather than machine-readable.
-
Eugene Mayevski 'Callback over 13 years@George They try to guess the output format and parse it. Some clients recognize hundreds of formats.
-
-
Nathan Osman over 13 yearsThen how do graphical FTP clients enumerate files?
-
Oded over 13 years@George Edison - they probably have a list of commonly used formats and parse those.
-
Oded over 13 years@George Edison - See the answer from @Eugene Mayevsky, these are apparently done through extensions to the FTP standard.
-
Nyerguds over 10 years@NathanOsman - I looked into the code of FileZilla on Sourceforge, and... it's not pretty, heh. Trial and error of about a dozen different formats.