Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ftplib
- import os, datetime
- print("Fetching files now")
- host = "Place FTP IP here Sans port"
- username = "Place Hosthavoc username here "
- password = "place Hosthavoc password here "
- directory = "/Place FTP IP HERE/ConanSandbox/Saved/Logs "
- ftp = ftplib.FTP()
- ftp.connect(host, ) ((Place port after host, and delete this message))
- ftp.login(username, password)
- ftp.cwd(directory)
- print("Printing files in dir: " + directory)
- files = []
- path = os.path.join(os.getcwd(), datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
- os.makedirs(path)
- ftp.dir(files.append)
- for log in files:
- print(log)
- filename = log.split(" ")
- ftp.retrbinary("RETR " + filename[len(filename) - 1], open(path + "\\" +filename[len(filename) - 1] , 'wb').write)
- ftp.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement