Reputation: 454
I have two FTP server a and b, I need to copy files from a server to b server. Downloading the file from a and upload to b is too complicate, I want to write a script by python to do this on my desktop, just type the command below it will do the job.
python syncftp.py a.com(source server) folder(folder name in source server)
b. com(destination server) folder(destination folder name)
but after some google, still can't find a good way to sync two ftp server just like dropbox. Is there any other way to do this? thanks.
Upvotes: 3
Views: 6614
Reputation: 23500
For starters, you have http://www.csync.org/ which is sort of a rsync (but since rsync only works with SSH and not FTP) but for HTTP/FTP transfers.
If you don't like that option there's always "lftp" or "curlftpfs", stackoverflow has a sister-site which provides your answer:
https://serverfault.com/questions/24622/how-to-use-rsync-over-ftp
if THAT doesn't give you anything, well then you always have ftplib in python: http://docs.python.org/library/ftplib.html
from ftplib import FTP
ftpretr = FTP('get.ftp.com') # connect to host, default port
ftpretr.login() # user anonymous, passwd anonymous@
ftpretr.retrbinary('RETR README', open('README', 'wb').write)
ftpretr.quit()
ftpsend = FTP('send-to.ftp.com','login','password')
ftpsend.storbinary('STOR todo.txt', open('README','rb'))
ftpsend.quit()
Now i can't help you more then that tbh without doing everything for you and i'm guessing you want to learn? use sys.argv[] to fetch input/output files and also for source-host and desition perhaps.
Enjoy! :)
Upvotes: 3