| Author |
RunTime.exec() and FTP
|
Judy Collins
Greenhorn
Joined: Oct 07, 2004
Posts: 20
|
|
Hi Guys, On WinXP, I am using String command ="cmd /c ftp -v -s: cmd.txt " Runtime.getRuntime().exec(command); .... ..... FTP Command is supposed to get a file from remote server, but as long as my program is running it does not get the file. Once I kill my program all of a sudden file pops up. But if I leave my program running file never shows up. Any ideas, help is greatly appreciated.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
It appears that you have not provided for consuming the stdout and stderr streams from the process that your exec() creates. The ftp program is probably trying to write something - since you don't read it, the program hangs. Bill
|
 |
Stephen Huey
Ranch Hand
Joined: Jul 15, 2003
Posts: 618
|
|
In other words, you might need to do something like this: It's like milking a cow. She's all pent-up, wanting that release, and if you don't draw it out of her, she can get quite ornery and not behave the way you'd like! Ok, that's my first and maybe last ranch analogy here at JavaRanch...
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
To continue Stephans analogy - his code only pulls on one teat - the stdout stream. If the program also write to std err, you need to write a separate Thread to suck on that teat too. - ewww Bill
|
 |
Judy Collins
Greenhorn
Joined: Oct 07, 2004
Posts: 20
|
|
Thank you guys!
|
 |
 |
|
|
subject: RunTime.exec() and FTP
|
|
|