Question

I am writing FTP client that should work for at least Windows and Linux FTPs. BUt before I proceed, I want answer to these questions.

  1. In which order files are listed when FTP ls -lt command is used for the FTP server on the Linux?
  2. Is there any specific format/logic in which all Linux FTP servers provide the list of files? e.g. DateTime stamp is going to be there always and files are listed in the descending order of the "date modfied" or something like this.
  3. In which order files are listed when FTP ls -lt command is used for the FTP server on the Windows?
  4. Is there any specific format/logic in which all Windows FTP servers provide the list of files?
  5. Can you direct me to some documentation which helps to understand this? Is there any standard defined for this?

Note: I tried command on Windows and Linux FTP servers but I could not figure out any specific logic/format.

Was it helpful?

Solution

ls is a client command. When your client gets ls -lt from the user, you issue a LIST command to the server and it's up to your client to parse the data returned and sort it by time. The data returned by the ftp server when you use the LIST command is similar to the output of ls, but it can vary from server to server. See: http://cr.yp.to/ftp/list.html

OTHER TIPS

The format of the FTP ls / dir commands is server implementation dependent. It is unlikely you could rely on the order of an ls -lt command within ftp. Some server implementations may give you name order, others may give you time order.

Newer FTP servers should hopefully implement RFC 3659, particularly the MLSD and MLST commands. The format of the response for these commands -- used for listing files and directories, in a machine-parseable format -- is strictly defined by the RFC, and thus should will be the same across underlying platforms/OSes.

Unfortunately, the MLSD/MLST commands, while addressing the format of the responses, make no guarantee about the ordering of the files within a listing; that is something that your client would need to handle.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top