[
https://issues.apache.org/jira/browse/NET-574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14591786#comment-14591786
]
Sebb commented on NET-574:
--------------------------
Note: I just tried connecting to ibiblio.org; it responds:
{noformat}
220 ProFTPD Server
Connected to ibiblio.org on 21
...
MLST
250-Start of list for /
modify=20110406221708;perm=fle;type=cdir;unique=13U40;UNIX.group=0;UNIX.mode=0755;UNIX.owner=0;
/
250 End of list
{noformat}
So the ProFTPD server can return correctly formatted output. I don't know why
it is failing in your case.
Note that you can use the examples jar as follows to send an MLST request:
{noformat}
java -jar commons-net-examples-3.3.jar FTPClientExample -t host username
password path
{noformat}
The examples jar must be in the same folder as the main NET jar.
http://commons.apache.org/proper/commons-net/#Examples
> FTPClient.mlistFile returns null timestamps in FTPFile.getTimestamp
> -------------------------------------------------------------------
>
> Key: NET-574
> URL: https://issues.apache.org/jira/browse/NET-574
> Project: Commons Net
> Issue Type: Bug
> Components: FTP
> Affects Versions: 3.3
> Environment: On Debian linux with proftpd server
> Reporter: Nicolas Leclerc
>
> In FTPClient mlistFile("test.txt") :
> {code:title=FTPClient.java|borderStyle=solid}
> public FTPFile mlistFile(String pathname) throws IOException
> {
> boolean success =
> FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
> if (success){
> String entry = getReplyStrings()[1].substring(1); // skip leading
> space for parser
> return MLSxEntryParser.parseEntry(entry);
> } else {
> return null;
> }
> }
> {code}
> getReplyStrings() return :
> 250-Start of list for test.txt
> 250-modify=20150616133640;perm=adfrw;size=83752220;type=file;unique=23U8FE039C;UNIX.group=32;UNIX.mode=0644;UNIX.owner=2005;
> /data/test.txt
> 250 End of list
> So getReplyStrings()[1].substring(1) return
> 50-modify=20150616133640;perm=adfrw;size=83752220;type=file;unique=23U8FE039C;UNIX.group=32;UNIX.mode=0644;UNIX.owner=2005;
> /data/test.txt
> {code:title=MLSxEntryParser.java|borderStyle=solid}
> public FTPFile parseFTPEntry(String entry) {
> String parts[] = entry.split(" ",2); // Path may contain space
> if (parts.length != 2) {
> return null;
> }
> FTPFile file = new FTPFile();
> file.setRawListing(entry);
> file.setName(parts[1]);
> String[] facts = parts[0].split(";");
> boolean hasUnixMode =
> parts[0].toLowerCase(Locale.ENGLISH).contains("unix.mode=");
> for(String fact : facts) {
> String []factparts = fact.split("=");
> // Sample missing permission
> // drwx------ 2 mirror mirror 4096 Mar 13 2010 subversion
> //
> modify=20100313224553;perm=;type=dir;unique=811U282598;UNIX.group=500;UNIX.mode=0700;UNIX.owner=500;
> subversion
> if (factparts.length != 2) {
> continue; // nothing to do here
> }
> String factname = factparts[0].toLowerCase(Locale.ENGLISH);
> String factvalue = factparts[1];
> String valueLowerCase = factvalue.toLowerCase(Locale.ENGLISH);
> if ("size".equals(factname)) {
> file.setSize(Long.parseLong(factvalue));
> }
> else if ("sizd".equals(factname)) { // Directory size
> file.setSize(Long.parseLong(factvalue));
> }
> else if ("modify".equals(factname)) {
> (...)
> {code}
> 50-modify not correspond to modify, so the parser not find the date
> Possible patch :
> {code:title=FTPClient.java|borderStyle=solid}
> public FTPFile mlistFile(String pathname) throws IOException
> {
> boolean success =
> FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
> if (success){
> String entry = getReplyStrings()[1].substring(4); // skip leading
> (...)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)