Format of the data returned by the FTP LIST command?

◇◆丶佛笑我妖孽 提交于 2019-12-10 03:52:06

问题


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?


回答1:


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.




回答2:


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.




回答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



来源:https://stackoverflow.com/questions/4564603/format-of-the-data-returned-by-the-ftp-list-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!