Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ftplib # https://pastebin.com/0mhRBnBe
- def ftp_download(dir_path, ftp_file):
- try:
- ftp = ftplib.FTP('website.net')
- ftp.login(user = 'user', passwd = 'password')
- ftp.cwd('/public_html/{0}'.format(dir_path))
- ftp.retrbinary('RETR {0}'.format(ftp_file), open(ftp_file, 'wb').write, 1024)
- ftp.storbinary('STOR {0}'.format(ftp_file), open(ftp_file, 'rb'))
- ftp.quit()
- print ('Succes download file: {0}'.format(ftp_file))
- except Exception as ftp_error:
- print (ftp_error)
- print ('Welcome to ftplib!')
- dir_path = input('Type path location.\n Example: {0}: '.format('wp-content/js_composer/ or None for dir <public_html>'))
- ftp_file = input('Type ftp_file.\n Example: {0}: '.format('js_composer.php'))
- ftp_download(['', dir_path][dir_path is not 'None'], ftp_file)
Advertisement
Add Comment
Please, Sign In to add comment