File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to execute ftp commands from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to execute ftp commands from java" Watch "how to execute ftp commands from java" New topic
Author

how to execute ftp commands from java

twity Panu
Greenhorn

Joined: Jan 31, 2007
Posts: 7
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......
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You are almost there with the code you have. Have a read of this.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
twity Panu
Greenhorn

Joined: Jan 31, 2007
Posts: 7
Can i get some suggestion of how to upload a file in server using ftp.......
in java.....
pls reply
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
Did the article Paul mentioned make sense to you? If not, which parts you did you have problems with?


Ping & DNS - updated with new look and Ping home screen widget
 
Consider Paul's rocket mass heater.
 
subject: how to execute ftp commands from java
 
Similar Threads
Problem in executing shell script using JSP
FTP using exec(String command) of Runtime
execute ftp commands using java API
Execute "echo $BASHPID" in Linux using Java
Redirect output from stderr, stdout to a JTextArea