tags:

views:

3355

answers:

5

I have a java application, which copies or moves a bunch of giga files from one ftp server to another. Currently it copies a file from the first fpt server to the local computer (where it runs) using ftp get and then copies it to the second ftp server using ftp put. I use net library from apache.

Is it possible to copy it directly from one ftp server to another bypassing the local computer? One idea is to create a java telnet session and and send a couple of ftp commands. Will it work? Any other suggestions?

+4  A: 

That will certainly work. If you can use rcp(1) or scp(1), however, you don't need the intermediate copy or a telnet session. Simply use

$ scp user@sys1:file user@sys2:file

If you do use a remote session, consider using ssh(1) instead of telnet.

Charlie Martin
+1  A: 

Telnet/SSH should work. Find a usable java telnet client library and take it from there...

Here's an article on scripting a telnet session with Java.

ykaganovich
+3  A: 

Yes, in theory this is possible due to the interesting way that FTP works. In practice, it is likely to require a custom FTP "client" in the middle, working with two servers.

The server-to-server transfer scenario is described and illustrated schematically in Section 5.2 of the FTP RFC (959). In a nutshell, one server is sent a PASV command, which returns an IP address and port number to the middle-man. The middleman sends this to the other server in a PORT command, and that server establishes a data connection directly to the first server.

erickson
+2  A: 

Server-to-server FTP transfer is also called "FXP". Try to search for "fxp java" in google.

For example: this page could be useful.

G B
A: 

I know a PHP script. You can use this to move file from server to server without SSH access. It is very fast and can move multi files: http://dlvn.net/web-development/move-files-from-server-to-server/