You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Clark Stuth <Cl...@carfax.com> on 2016/06/06 14:53:11 UTC

[NET] - FtpClient.getStatus(path) does not seem to be working as documented.

We think we've identified a mis-documented feature with FTPClient in
commons-net, specifically the getStatus() methods. According to the FTP
protocol, STAT should return server status information. However,
according to the FTPClient documentation
(https://github.com/apache/commons-net/blob/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java#L3510), the STAT command is used to retrieve remote file listings. As a result,
we are running into an issue with how Spring Framework Integration is
using the FtpClient.getStatus(path) command.

From our own testing it does not appear that the FTP Server's stat()
command returns a different result when presented with a pathname or
not.  The STAT command primarily seems to return server and connection
status information, not file information.

The following two examples will show the FTP Server Output when
presented with the STAT command against no path, a file that exists, and
an invalid path (file does not exist).
OpenVMS Implementation:
https://raw.githubusercontent.com/clarkstuth/spring-ftp-template-spike/master/status_command_OpenVMS.txt 
PureFTPD Implementation:
https://raw.githubusercontent.com/clarkstuth/spring-ftp-template-spike/master/status_command_PureFTPD.txt 

Is it possible we are misinterpreting what this stat command should be
doing?  It appears the FTP protocol functions differently than how this
method is documented.

If the functionality of the STAT command is vendor dependent, would it
be possible to update the documentation to include this?

Thanks,
Clark Stuth, Sean Lally
Carfax Software

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org

Re: [NET] - FtpClient.getStatus(path) does not seem to be working as documented.

Posted by ec...@zusammenkunft.net.
According to RFC959 the STAT command can be used with a pathname (and without while transfer is ongoing). I think your problem in the sample output is, that your FTP command client is not really issuing a STAT command. I would recommand you use a raw TCP connection like netcat/telnet to debug the command or at least use "QUOTE STAT /filename" if the client supports it.

I think it is rarely used for its actual return code as it is hard to parse but it is used as a NOP-like command to keep control connection active or signal interactions after file transfers (some servers need that to recognize complete transfers).

BTW, I think this is a users-list question.

Bernd
-- 
http://bernd.eckenfels.net

-----Original Message-----
From: Clark Stuth <Cl...@carfax.com>
To: "dev@commons.apache.org" <de...@commons.apache.org>
Sent: Di., 07 Juni 2016 21:53
Subject: [NET] - FtpClient.getStatus(path) does not seem to be working as documented.

We think we've identified a mis-documented feature with FTPClient in
commons-net, specifically the getStatus() methods. According to the FTP
protocol, STAT should return server status information. However,
according to the FTPClient documentation
(https://github.com/apache/commons-net/blob/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java#L3510), the STAT command is used to retrieve remote file listings. As a result,
we are running into an issue with how Spring Framework Integration is
using the FtpClient.getStatus(path) command.

From our own testing it does not appear that the FTP Server's stat()
command returns a different result when presented with a pathname or
not.  The STAT command primarily seems to return server and connection
status information, not file information.

The following two examples will show the FTP Server Output when
presented with the STAT command against no path, a file that exists, and
an invalid path (file does not exist).
OpenVMS Implementation:
https://raw.githubusercontent.com/clarkstuth/spring-ftp-template-spike/master/status_command_OpenVMS.txt 
PureFTPD Implementation:
https://raw.githubusercontent.com/clarkstuth/spring-ftp-template-spike/master/status_command_PureFTPD.txt 

Is it possible we are misinterpreting what this stat command should be
doing?  It appears the FTP protocol functions differently than how this
method is documented.

If the functionality of the STAT command is vendor dependent, would it
be possible to update the documentation to include this?

Thanks,
Clark Stuth, Sean Lally
Carfax Software

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [NET] - FtpClient.getStatus(path) does not seem to be working as documented.

Posted by sebb <se...@gmail.com>.
On 6 June 2016 at 15:53, Clark Stuth <Cl...@carfax.com> wrote:
> We think we've identified a mis-documented feature with FTPClient in
> commons-net, specifically the getStatus() methods. According to the FTP
> protocol, STAT should return server status information. However,
> according to the FTPClient documentation
> (https://github.com/apache/commons-net/blob/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java#L3510), the STAT command is used to retrieve remote file listings.

Actually STAT is used for both; see below.

> As a result,
> we are running into an issue with how Spring Framework Integration is
> using the FtpClient.getStatus(path) command.
>
> From our own testing it does not appear that the FTP Server's stat()
> command returns a different result when presented with a pathname or
> not.  The STAT command primarily seems to return server and connection
> status information, not file information.

I think you are confusing the server STAT command with the ftp client
'status' command.

> The following two examples will show the FTP Server Output when
> presented with the STAT command against no path, a file that exists, and
> an invalid path (file does not exist).
> OpenVMS Implementation:
> https://raw.githubusercontent.com/clarkstuth/spring-ftp-template-spike/master/status_command_OpenVMS.txt
> PureFTPD Implementation:
> https://raw.githubusercontent.com/clarkstuth/spring-ftp-template-spike/master/status_command_PureFTPD.txt

Those examples show the ftp client 'status' command.

This is not the same thing as the FTP protocol STAT command.

There is a difference between the commands that can be issued to an
FTP client and the commands that an FTP server accepts.
An FTP client translates the commands you provide into commands that
FTP servers understand.

The NET FTP code talks directly to the FTP server, so uses server commands.

The FTP server commands are documented in RFC 959.
If you search for STAT in
https://www.ietf.org/rfc/rfc959.txt

you should find it at the bottom of page 33.

This explains how the server interprets a STAT command on its own and
with a filename parameter.

> Is it possible we are misinterpreting what this stat command should be
> doing?

Yes

> It appears the FTP protocol functions differently than how this
> method is documented.

The Javadoc says that it issues the STAT command to the server, which
is correct.
However that is not the same as the "status" command that an FTP
client may accept.

> If the functionality of the STAT command is vendor dependent, would it
> be possible to update the documentation to include this?

Please note that this is off-topic for the developer list.

So if you want further support on how to use the NET library, please
subscribe to the Commons User mailing list and ask there.

> Thanks,
> Clark Stuth, Sean Lally
> Carfax Software
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org