Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic

execute ftp commands using java API

 
twity Panu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
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 ]
 
twity Panu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
please help,i want some perfect solution..................
I mainly want to upload a file from my local machine to server..
using ftp mput.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question to multiple forums. You now have answers here and in this duplicate thread. CarefullyChooseOneForum
 
Hot dog! An advertiser loves us THIS much:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!