heres an example for reading the process output:
http://www.objects.com.au/
Main Topics
Browse All TopicsI am transporting a file via FTP or NCFTP during java runtime...
Runtime rt = null;
Process proc = null;
String commandLine_ = "my ftp/ncftp commandline...";
try {
rt = Runtime.getRuntime();
proc = rt.exec(commandLine_);
} catch (IOException ie) {
ie.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
though the file is transported successfully, it does not really provide information that the file is transported properly...
May I ask how to acquire the return value of the FTP/NCFTP commadline during java runtime so that I can determine what really happens during the commandline runtime execution...
thanks in advanced experts... =)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
heres an example for reading the process output:
http://www.objects.com.au/
Also this might come in handy: http://www.javaworld.com/j
>> though the file is transported successfully, it does not really provide information that the file is transported properly...
Like described above, reading the stdout and stderr streams from the created process will give information about the execution of said external process. However, the absence of _any_ output on stderr should indicate succes.
Did you know that it is quite easy to do ftp up-/downloads in Java without external tools?
URL url = new URL("ftp://username:passwo
URLConnection urlcon = url.openConnection();
OutputStream ftpout = urlcon.getOutputStream();
// write your file data into ftpout
ftpout.close();
If something goes wrong you'll get an exception.
I agree that it makes a lot more sense to do this with Java code rather than native.
On a recent project, I went through a number of FTP client packages. The file transfer was a critical component and I started out with the idea that a commercial package would be appropriate - I was not going to skimp on this part. After running into problems with a number of tools, I ended up with the Jakarta Commons Net package. It worked very well and it was the only one I tested that would correctly do FTP restart with files larger than 4GB.
You can find it at: http://jakarta.apache.org/
As said in the articles that you have recommended... I tried waitFor() method and it is working fine...
Although if an error has occured during connection or transfer, waitFor() still returns a 0 value (success)...
int exitVal = proc.waitFor();
Is this normal...?
Also, I used getInputStream() to log the status of my transfer... However, I found out that sometimes, even during a successful transfer, I get this message in my log...
200 PORT command successful.
150 Opening ASCII mode data connection for myfile.txt.
452 Error writing file: No space left on device.
ftp: 93 bytes sent in 0.00Seconds 93000.00Kbytes/sec.
but usually it is like this...
200 PORT command successful.
150 Opening ASCII mode data connection for myfile.txt.
226 Transfer complete.
ftp: 93 bytes sent in 0.00Seconds 93000.00Kbytes/sec.
With this behavior, I may still not be able to confirm if the file is really transferred properly or not unless I check the file in its destination folder...
May I ask if I just missed a step so that this behavior does not happen...
With regards to using URL instead, I have not yet tried it for my ftp or ncftp for transffering data (mput/ncftpput)...
May I ask how should I do my mput and ncftpput by doing ftp/ncftp in URL...
Thanks again experts... =)
Business Accounts
Answer for Membership
by: girionisPosted on 2004-06-30 at 23:43:21ID: 11443979
Get the input and output streams of the process and read the response. Then parse it and get information about the state of it.