commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Yasuda <constructic...@yahoo.com>
Subject Re: NET FTPClient changeWorkingDirectory
Date Tue, 05 Apr 2005 19:12:25 GMT
Jeffrey,
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.connect("hostname");
ftp.login("root", "password");

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

// Code used for a Process
Process df_proc =
Runtime.getRuntime().exec("/usr/sbin/df");
buffStream = new BufferedReader(new
InputStreamReader(df_proc.getInputStream()));

resultFld.setText("");
while (null != (inputLine = buffStream.readLine())) {
    resultFld.append(inputLine + "\n");
}
resultFld.setCaretPosition(0);
buffStream.close();
ftp.disconnect();


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.

Gary

--- "Jeffrey D. Brekke" <jbrekke@wi.rr.com> 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                                  
> jbrekke@wi.rr.com
> Wisconsin,  USA                                    
> brekke@apache.org
>                                                     
> ekkerbj@yahoo.com
> http://www.bloglines.com/blog/jbrekke              
> ekkerbj@gmail.com



		
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest

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


Mime
View raw message