#-*-Coding:utf-8-*-#!/usr/bin/env Python3 # Name:alenx from ftplib import FTP def ftpconnect (): Ftp_server = ' 10.40.0.11 ' username = ' ftpadmin ' password = ' ftpadmin ' FTP = FTP () ftp.set_debuglevel (2) Ftp.connec T (ftp_server) ftp.login (username, password) return ftp def downloadfile (): RemotePath = "/HOME/PUB/DOG.J PG "FTP = Ftpconnect () print (Ftp.getwelcome ()) BufSize = 1024 LocalPath = ' f:\\test\\dog.jpg ' fp = ope
N (localpath, ' WB ') ftp.retrbinary (' RETR ' + RemotePath, Fp.write, bufsize) ftp.set_debuglevel (0) Fp.close () Ftp.quit () def uploadfile (): RemotePath = "/opt/ftpadmin/redis.sh" ftp = Ftpconnect () bufsize = 1024 L
Ocalpath = '/users/admin/redis.sh ' fp = open (LocalPath, ' RB ') ftp.storbinary (' STOR ' + remotepath, FP, bufsize) Ftp.set_debuglevel (0) Fp.close () ftp.quit () def getlist (): FTP = Ftpconnect () print (' * ' *) ftp. Dir () Ftp.dir ('/aaa/') print (' + ' *) if __name__ = = "__main__": # UploadFile () getlist ()