tags:

views:

267

answers:

2

Hey guys,

I have two ftp servers with fxp enabled on both, I'm just wondering how I would transfer a file between the two servers in Python? I was told curl wouldnt do it, but maybe ftplib will do.

so, the file (file.txt) is in '/personal/' FTP1 and I want to transfer that to FTP2 also to the same place, '/personal/'

Any ideas on how to do this?

A: 

The simplest thing to is call the shell from within python, and then scp your file from one computer to the other. It shouldn't be very costly, almost nothing compared with the transfer costs, so don't worry about performance.

Just try

os.system('scp myfile othermachine.jack.com:/transfers')

Or something of the sort. See the documentation of scp. On Windows, you'll need CYGWIN for this.

Of course you can also go for ftp-style copies. Just set up an Apache on the target machine where you can write. But I'd go for the scp solution :)

nes1983
ah okay, the ftp servers arent mine but I can definitely ssh FTP1 and do that.. but I dont have shell access on FTP2I will try that out, thanks!
jack
Don't forget accepting my answer so I can have SCORE!
nes1983
Caching! Come again any time :)
nes1983
+1  A: 

You should use ftplib (http://docs.python.org/library/ftplib.html)