0

I'm writing an FTP server with Java, and now I want to answer to LIST command.Sending only file names is enough, and I don't need to send file size, owner, permission, etc. It seems that just sending some strings, as file names, does not satisfy the client (I tried both ASCII and binary formats). How can I find out what does an FTP client expect as a reply?

I'm testing my server using FireFTP and FileZilla

Pedram
  • 103
  • 1
  • 2
  • 8
  • How about just reading the one paragraph about the LIST command in the RFC instead? If you want particular support for different programs then you'll have to read their documentation, but I doubt they expect a particular format from a LIST command - that wouldn't work that great. – Voo May 27 '11 at 17:35
  • 1
    I couldn't find any thing about LIST response standard in RFC. – Pedram May 27 '11 at 17:53
  • So either your search key is broken or you didn't search.. Because otherwise the first search for "LIST " will show a nice neat paragraph on p32 – Voo May 27 '11 at 18:10
  • As I said in the question I sent file names followed by `\r\n` but the clients does not show anything.It works with ftp command in linux but does not with FireFTP and FileZilla. – Pedram May 27 '11 at 18:25

2 Answers2

2

The canonical place to look is the relevant RFC: http://www.ietf.org/rfc/rfc959.txt

Unfortunately, in this particular instance the RFC is pretty vague:

        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.

In order to ensure compatibility with existing FTP clients, your best bet is to look at some widely-deployed FTP server software and emulate the format of its output.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
2

If you want to create a compatible FTP server, you need to handle LIST and NLST (standard commands) and also MLST and MLSD extension commands.

Format for LIST command is not defined anywhere and there are about 400 formats encountered in the world. Using Unix ls format or Windows DIR format would work with most clients as these are formats quite widespread and well supported by the clients.

NLST is the list of file names only.

MLST and MLSD use the machine-parseable format (this is what M letter stands for) which is described in RFC 3659. It's easier for the clients to handle and it's support is very welcome.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • Thanks.Now about the LIST where can I find specific format for FireFTP or Filezilla? – Pedram May 28 '11 at 02:10
  • And how can I make client to send MLST instead of LIST?Is it enough to send it in FEAT answer? – Pedram May 28 '11 at 02:15
  • @Pedram Clients usually understand plenty of formats, and they all understand common Unix ls format. So if you stick to unix format, you are almost guaranteed to get positive results with the client. Regarding MLST/MLSD - our client favors MLSD support to regular List so if MLSD is supported, it will be used. THis is client-dependent though. – Eugene Mayevski 'Callback May 28 '11 at 12:22