commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kurt Kurniawan" <>
Subject RE: NET FTPClient changeWorkingDirectory
Date Wed, 06 Apr 2005 00:42:32 GMT


I did a little test with my own version of program.
In my case, it works fine.

I picked up a file from a W$ box and transfer to HPUX.
Imagining that you use a root access to the box, that should not be any access rights problems.
In many cases, this is the root cause.

I suggest to check with the statement: ftp.getReplyString()
to make sure that you actually logged in to the machine before picking up the file.

Good luck !

I cut and paste a part of the code that I used for testing:

public boolean executeDFTP(String intname, String filename)

	return true;
 public void getDataFile( String source,
                   String username,
                   String password,
                   String sourceFolder,
		   String target,
		   String targetUser,
		   String targetPasswd,
                   String destinationFolder,
		   String filename)
      // Connect and logon to FTP Server
      FTPClient ftp = new FTPClient();
      FTPClient ftp2= new FTPClient();
      ftp.connect( source );
      ftp.login( username, password );
      System.out.println("Connected to source: " +
           source + ".");
      ftp.changeWorkingDirectory( sourceFolder );
      ftp2.connect( target );
      ftp2.login( targetUser, targetPasswd );
      System.out.println("Connected to target: " +
           target + ".");
      ftp2.changeWorkingDirectory( destinationFolder ); //<---------- This works!
      boolean isOK=ftp2.storeFile(filename,ios);
      if (isOK){
	System.out.println("The transfer was succesful !");     
      // Logout from the FTP Server and disconnect
    catch( Exception e )

"What I hear, I forget. What I see, I remember.
And what I do, I understand."
~ Chinese Proverb

Kurt Kurniawan

-----Original Message-----
From: Gary Yasuda []
Sent: Wednesday, 6 April 2005 5:12 AM
To: Jakarta Commons Users List
Subject: Re: NET FTPClient changeWorkingDirectory

I am trying to FTP into HP-UX and AIX systems, read a
file or capture the output of a process, and display
them into a TextArea.

TextArea resultFld = new TextArea(50,80);
FTPClient ftp = new FTPClient();
BufferedReader buffStream;
InputStream inStream = null;
String inputLine;
String path = "/etc";

ftp.login("root", "password");

// Code used for Capturing a File
ftp.changeWorkingDirectory(path); // PROBLEM
buffStream = new BufferedReader(new

// Code used for a Process
Process df_proc =
buffStream = new BufferedReader(new

while (null != (inputLine = buffStream.readLine())) {
    resultFld.append(inputLine + "\n");

I am not well versed in doing remote capturing from a
single interface like this.  If you know of more
efficient ways to code this kind of functionality, I
am open to suggestions.


--- "Jeffrey D. Brekke" <> wrote:
> Gary,
> I think you may need to give us the context ( ie:
> more code ) around
> what you are doing.  Constant string or variable
> shouldn't matter.
> Sometimes while I'm tracking these types of issues
> down, I write a small
> little test case with out my *application* getting
> in the way.  Maybe
> you've tried that already?
> Gary Yasuda wrote:
> > I am using the commons-net-1.3.0.jar libraries.
> >
> > The changeWorkingDirectory(String) requires a
> Class
> > String as the path.  If I put the path between
> double
> > quotes, the directory is changed.  If I use a
> String
> > variable, the directory is not changed.
> >
> > For example,
> > FTPClient ftp = new FTPClient();
> > ...
> > ftp.changeWorkingDirectory("/tmp");
> >
> > This will change me to the /tmp directory.
> >
> > However,
> > String dir = "/tmp";
> > ftp.changeWorkingDirectory(dir);
> >
> > For some reason, I will not be placed in the /tmp
> > directory that is assigned to a String variable.
> >
> > Even this will not work:
> > ftp.changeWorkingDirectory(dir + "/test");
> >
> > Is this is a known bug?
> >
> > Gary
> Jeffrey D. Brekke                                 
> Wisconsin,  USA                                   

Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.

To unsubscribe, e-mail:
For additional commands, e-mail:

CAUTION: This message may contain confidential information intended only for the use of the
addressee named above. If you are not the intended
recipient of this message, any use or disclosure of this message is prohibited. If you received
this message in error please notify email Administrators immediately.  You must obtain all
necessary intellectual property clearances before doing anything other than displaying this
message on your monitor. There is no intellectual property licence.  Any views expressed in
this message are those of the individual sender and may not necessarily reflect the views
of BIG W Discount Stores.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message