files to any machine with python and socketsfrom any machine running an ftp server example - pp \internet\ftp\mirror\downloadflat py #!/bin/env python ""##############################################################################use ftp to copy (downloadall files from single directory at remote site to directory on the local machinerun me periodically to mirror flat ftp site directory to your isp accountset user to 'anonymousto do anonymous ftpwe could use try to skip file failuresbut the ftp connection is likely closed if any files failwe could also try to reconnect with new ftp instance before each transferconnects once nowif failurestry setting nonpassive for active ftpor disable firewallsthis also depends on working ftp serverand possibly its load policies ##############################################################################""import ossysftplib from getpass import getpass from mimetypes import guess_type nonpassive false passive ftp on by default in remotesite 'home rmi netdownload from this site remotedir and this dir ( public_htmlremoteuser 'lutzremotepass getpass('password for % on % (remoteuserremotesite)localdir (len(sys argv and sys argv[ ]or cleanall input('clean local directory first')[: in [' '' 'print('connecting 'connection ftplib ftp(remotesiteconnection login(remoteuserremotepassconnection cwd(remotedirif nonpassiveconnection set_pasv(falseconnect to ftp site login as user/password cd to directory to copy force active mode ftp most servers do passive if cleanallfor localname in os listdir(localdir)try to delete all locals tryfirstto remove old files print('deleting local'localnameos listdir omits and os remove(os path join(localdirlocalname)exceptprint('cannot delete local'localnamecount remotefiles connection nlst(for remotename in remotefilesif remotename in ('')continue mimetypeencoding guess_type(remotenamemimetype mimetype or '?/?maintype mimetype split('/')[ download all remote files nlst(gives files list dir(gives full details some servers include and ('text/plain''gzip'may be (nonenonejpg ('image/jpeg'none'transferring directories with ftplib