This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
URL url = new URL("ftp://admin:administrator@10.20.30.9"); URLConnection urlc = url.openConnection(); InputStreamReader isr = new InputStreamReader(urlc.getInputStream()); Process process = Runtime.getRuntime().exec(urlc + "cd SABB_APP dir"); BufferedReader input = new BufferedReader(isr); String s; while ((s = input.readLine()) != null) { System.out.println(s); }input.close(); I have done this thing for connection,but i want to execute mput and mget commands from java..I thought to use Runtime.getRuntime.exec() but was not able to do..... plaese help me out..... i have an urgency......
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
Welcome to JavaRanch.
While there's probably a way to make this work, be aware that Runtime.exec has several pitfalls (as explained here) that make it harder to work with interactive programs than it would at first appear.
I think you'd be much better off using an ftp client library like Jakarta Commons Net. It doesn't support mget and mput directly, though, so you'd have to code a simple loop. [ January 31, 2007: Message edited by: Ulf Dittmer ]