Bookmark Topic Watch Topic
  • New Topic

execute ftp commands using java API  RSS feed

 
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......
 
Rancher
Posts: 42972
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: 42972
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
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!