commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeffrey D. Brekke" <jbre...@wi.rr.com>
Subject Re: NET FTPClient changeWorkingDirectory
Date Wed, 06 Apr 2005 03:07:46 GMT

Comments are below, I think you may be overwriting the variable 
buffStream with another stream before reading the results?

Gary Yasuda wrote:
> 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")));

I'm assuming you are reading the buffStream inbetween these two blocks 
of code since you assign buffStream to the output the df command below. 
  Also, the javadocs for the retrieveFileStream() provide some 
information about using the completePendingCommand() to finsh up the 
transfer.

> // 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.

An example would be useful, I'll see if I have some laying around about 
reading data from retrieveFileStream() unless someone beats me to it.

-- 
=====================================================================
Jeffrey D. Brekke                                   jbrekke@wi.rr.com
Wisconsin,  USA                                     brekke@apache.org
                                                     ekkerbj@yahoo.com
http://www.bloglines.com/blog/jbrekke               ekkerbj@gmail.com


---------------------------------------------------------------------
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