FTP "ls -lt" command: How does it list the file details for Linux FTP and Windows FTP server?
Asked Answered
C

3

10

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.

Collectivity answered 19/7, 2012 at 4:27 Comment(1)
May I know what's wrong with this question that people have downvoted for it? At least mention the reason while downvoting so that questioner can avoid same mistake in future.Collectivity
T
8

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

Topsail answered 19/7, 2012 at 4:59 Comment(0)
K
4

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.

Kelle answered 19/7, 2012 at 4:51 Comment(0)
A
1

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.

Anode answered 18/1, 2016 at 2:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.