commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Baumgartner <poindex...@yahoo.com>
Subject Re: [NET] Help with change directory
Date Wed, 27 Jul 2011 02:39:52 GMT
Thank you so much - the debugging line was exactly what I needed.  I am now able to ftp away!

--- On Tue, 7/26/11, sebb <sebbaz@gmail.com> wrote:

From: sebb <sebbaz@gmail.com>
Subject: Re: [NET] Help with change directory
To: "Commons Users List" <user@commons.apache.org>
Date: Tuesday, July 26, 2011, 9:38 AM



I forgot to mention that you can add debug tracing (as per the example code):

        ftp.addProtocolCommandListener(new PrintCommandListener(new
PrintWriter(System.out), true));

> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Tuesday, July 26, 2011 07:40 AM
> To: Commons Users List
> Subject: Re: [NET] Help with change directory
>
> On 25 July 2011 21:41, Diane Baumgartner <poindextra@yahoo.com> wrote:
>> I'm new to Apache Commons  (3.0.1), and am writing a Java program to FTP a file
on my local server to an FTP server on the same network.
>
> First, please prefix the subject line with the Commons component; in this case [NET]
as I have done in this reply.
>
>> First, I'd like to make sure that changeWorkingDirectory() changes the directory
on the remote machine.  It's not clear from the documentation.
>
> The command corresponds with the standard FTP command CWD, which attempts to change the
remote directory.
>
>> The first thing hat happens is that the "Change Directory didn't work" prints out. 
but I don't know what went wrong.
>> So, I'm trying to use getReply() for more information, but my program hangs on that
line.  I know this becuase the line before it prints, but not the line after it.
>>
>> Here's a code snippet:
>>
>> FTPClient ftp = new FTPClient();
>> ftp.connect (server);
>>
>> // status checking here - print statements indicate that connect was
>> successful
>>
>> boolean OK = ftp.changeWorkingDirectory ("/tmp/dir_name"); if {OK} {
>>   System.out.println ("Change directory worked"); } else {
>>   System.out.println ("Change directory didn't work");
>>   system.out.println ("The FTP Reply Code is");
>>
>>  reply = ftp.getReply();  // reply was defined as int before doing the
>> connect previous to this
>>   System.out.println (Reply);
>> }
>>
>> Thanks for any help you can offer.
>
> getReply() is intended for low-level programming; it fetches the response from the server,
so no wonder the code hangs.
>
> You need to use getReplyCode() and/or getReplyString().
>
> Have a look at the FTPClientExample code.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
> ---------------------------------------------------------
>
> NOTICE: The information contained in this electronic mail message is confidential and
intended only for certain recipients.  If you are not an intended recipient, you are hereby
notified that any disclosure, reproduction, distribution or other use of this communication
and any attachments is strictly prohibited.  If you have received this communication in error,
please notify the sender by reply transmission and delete the message without copying or disclosing
it.
>
> ============================================================================================
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message