Meaningless Drivel is fun!*
The moose likes Sockets and Internet Protocols and the fly likes Regarding FTP froma  remote server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Regarding FTP froma  remote server" Watch "Regarding FTP froma  remote server" New topic
Author

Regarding FTP froma remote server

Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Hello all,
I am hereby looking for a remote FTP and i am not able to figure how it can be done.

The scaneraio is : I have 3 servers namely A,B and C.

My program runs on C and it wants to do FTP from A to B on which JAVA is not running.

A,B,C are all Sloaris servers.

So can anyone help me out with Sample code to acheive the same.

Ftp from a to b sitting at C ?? Someone suggested me to use SOCKS proxy but i am not aware of it.

Thanks in advance,
Saurabh


Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Machines A and B need to have FTP servers running; Java is not required, and the operating system makes no difference. The client on machine C can be implemented using the Jakarta Commons Net library, which includes an FTP client.

Ftp from a to b sitting at C ??

I don't understand what you are asking here - your program is running on C, but the file should be transferred from A to B? Either ftp the file from A to C, and from there to B, or you can open a shell on A and initiate a direct ftp to B (or vice-versa). The Net library also has rexec/rcmd/rlogin facilities for that.
[ July 29, 2005: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Originally posted by Ulf Dittmer:
Machines A and B need to have FTP servers running; Java is not required, and the operating system makes no difference. The client on machine C can be implemented using the Jakarta Commons Net library, which includes an FTP client.


I don't understand what you are asking here - your program is running on C, but the file should be transferred from A to B? Either ftp the file from A to C, and from there to B, or you can open a shell on A and initiate a direct ftp to B (or vice-versa). The Net library also has rexec/rcmd/rlogin facilities for that.

[ July 29, 2005: Message edited by: Ulf Dittmer ]



Thanks Ulf,
My problem is since servers A & B are 3rd party external servers, so i cant do any changes as far as transfer is concerned. i.e. i cant transfer file from A to C and then from C to B.

So this is not the case.

Now the other option you gave was to open a shell on A and do a direct FTP to B, so the thing is can i open a shell on A from C using JAVA program.

If possible , then can i use Apache common's net library as suggested by you to open a shell on machine A as well.

Please help me out.If you have some sample code then that would be of great help to me.

Awaiting your reply.

Thanks in advance,
Saurabh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
I think it's strange that they would let you open a shell, but not transfer a file through one of your computer, but OK.

I don't have sample code; I've only used Commons Net for ftp, never for
remote login. I'd suggest reading up on the Unix commands that are mirrored by those facilities, and try it out in your environment.
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Originally posted by Ulf Dittmer:
I think it's strange that they would let you open a shell, but not transfer a file through one of your computer, but OK.

I don't have sample code; I've only used Commons Net for ftp, never for
remote login. I'd suggest reading up on the Unix commands that are mirrored by those facilities, and try it out in your environment.


Tell me can i upload a file from server A , using my JAVA program on server C and uploading the same on server B ? Is it possible through the commons net library?

Saurabh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Tell me can i upload a file from server A , using my JAVA program on server C and uploading the same on server B ? Is it possible through the commons net library?


Commons net implements client-side ftp. With it an app can connect anywhere where there's an ftp server, and upload and download files.
Your wording is not quite clear: you want to upload a file *FROM* C *TO* A, and then upload the same file *FROM* C *TO* B? Or do you want to download *FROM* A to C, and then upload that file *TO* B? But either way, it's possible as long as you have ftp servers on A and B.
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Originally posted by Ulf Dittmer:


Commons net implements client-side ftp. With it an app can connect anywhere where there's an ftp server, and upload and download files.
Your wording is not quite clear: you want to upload a file *FROM* C *TO* A, and then upload the same file *FROM* C *TO* B? Or do you want to download *FROM* A to C, and then upload that file *TO* B? But either way, it's possible as long as you have ftp servers on A and B.


I want to transfer a file from Server A to Server B where FTP services would be running as such but no explicit FTP Servers would be running and my JAVA program would be running on Server C.
So now tell me if i want to transfer a file from A to B where at both ends FTP services which are default of the OS are running, so can i transfer the file from A to B now, using COMMONS NET LIBRARY.

Thanks in advance,
Saurabh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
I guess what you call "ftp services" I call "ftp server", so let's assume that they're the same thing. I think you can achieve what you're trying to do, but you will need shell access to one of the machines. How that might work with Commons Net, I have no idea, but that is what rexec/rlogin/rcmd do, and Commons Net claims to implement those. The documentation should help you in that regard.
Of course, it might be simpler to write a shell script that does the remote login and ftp, and to just run that using the Runtime and Process classes. Even simpler, use no Java, and run the script from the command line, but maybe it's a requirement to control this from Java.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding FTP froma remote server
 
Similar Threads
These questions are bugging ...help!
SOCKS PROXY
FTP Task giving "Connection timed out: connect" Error
downloading all the files in a folder through ftp
FTP Upload