Hi I have been trying to make a FTP client using exec(...) method of java.lang.Runtime. I coded the client like this: Process p = (Runtime.getRuntime()).exec("ftp www.somesitename.com"); After this I obtain the InputStream and OutputSream associated with the process. Now the problem arise: (1). When I wrap the InputStream into BufferedReader then a call to readLine() method of BufferedReader results in no output (2). How one can pass the user name and password to this ftp connection using the output stream of the process Can someone help me find out a simple solution to creating FTP client using just the exec(...) method rather than using Sockets and ServerSockets. regards ashish sarin
Look at the 13.5 JProgressBar in FTP client application example in the magnificient book Swing 2nd ed. by Robinson and Vorobiev. But consider also what Sun says about Using sun.* packages [ April 23, 2004: Message edited by: Jose Botella ] [ April 23, 2004: Message edited by: Jose Botella ]
You need to spawn a new thread to read from the OutputStream because its going to block on calls to read. That way you can still get your interactive input into the new process' InputStream. I think using URL and URLConnection is easier:
or something like that. [ April 23, 2004: Message edited by: Joe Ess ]
Yes, if you're reading the stdout stream. Here's a runtime exec exercise I did. It's not 100% bug free: http://www.surfscranton.com/architecture/CmdServer.htm The server portion has the runtime exec stuff. Have you looked around for FTP APIs for Java? I've seen some open source or free packages mentioned but never tried any. That would give you the best possible control over FTP. This runtime exec stuff will get complicated in a hurry - reading stdout and errout on threads, synchronizing to examine results, etc.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
subject: FTP using exec(String command) of Runtime