Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run FTP.exe with/without IP Address, Username and password?  RSS feed

 
Vidyadhar Hegde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need some help.
I am trying to execute FTP.exe file with IP address from a java program using
Runtime.getRuntime().exec("path\FTP.exe someIPaddress");
statement.But what happening is, ftp is starting but not able to stay within the same program. And also it is not asking for username and password also. Even if I give the username and password along with IP address, it is not accepting.
So how do I execute this .exe file with/without options ?
Thanks.

------------------
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can do it this way by creating a file to use a a control file in which you write the open, setting the user and password, changing directories, putting files etc.(You can read the help associated withyour ftp program for the details) Then the command to ftp is
ftp -s:filename
You can pass this to runtime.exec() by creating a String array.
That answers the question you ask but, a better approach is to use the UrlConnection class to connect to the ftp server and communicate with it directly inside your java program

I hope this helps.
 
Chitra Sundaram
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carl,
This approach definitely works well or all files but the image files. The image files( gif & jpeg) come out to be empty.How can I bring these files.
Please help
Regards
Chitra
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!