Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format of the data returned by the FTP LIST command?

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?

like image 697
Nathan Osman Avatar asked Dec 30 '10 17:12

Nathan Osman


People also ask

What does the list command do in FTP?

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.

What command will give you a list of files on a FTP server?

dir -S = Lists files in bare format in alphabetic order. Exits from FTP. Get file from the remote computer.

What are FTP commands and replies?

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.


3 Answers

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.

like image 88
Oded Avatar answered Sep 27 '22 19:09

Oded


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.

like image 21
Eugene Mayevski 'Callback Avatar answered Sep 27 '22 18:09

Eugene Mayevski 'Callback


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

like image 38
Martin Avatar answered Sep 27 '22 18:09

Martin