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?
The LIST command is issued to transfer information about files on the server through a previously established data connection. When no argument is provided with the LIST command, the server will send information on the files in the current working directory.
dir -S = Lists files in bare format in alphabetic order. Exits from FTP. Get file from the remote computer.
There is typically a one-to-one correspondence between the command that the user issues and the FTP command sent across to the control connection. Each command is followed by a reply, sent from server to client. The replies are three-digit numbers, with an optional message following the number.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With