Reputation: 4751
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.
ls -lt
command is used for the FTP server on the Linux?ls -lt
command is used for the FTP server on the Windows?Note: I tried command on Windows and Linux FTP servers but I could not figure out any specific logic/format.
Upvotes: 10
Views: 56552
Reputation: 3089
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.
Upvotes: 1
Reputation: 143906
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
Upvotes: 8
Reputation: 2084
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.
Upvotes: 4