开发者

How to transfer a file between two FTP servers?

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?


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


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜