Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import ftplib
  2. import os, datetime
  3.  
  4. print("Fetching files now")
  5. host = "Place FTP IP here Sans port"
  6. username = "Place Hosthavoc username here "
  7. password = "place Hosthavoc password here "
  8. directory = "/Place FTP IP HERE/ConanSandbox/Saved/Logs "
  9. ftp = ftplib.FTP()
  10. ftp.connect(host, ) ((Place port after host, and delete this message))
  11. ftp.login(username, password)
  12.  
  13. ftp.cwd(directory)
  14. print("Printing files in dir: " + directory)
  15. files = []
  16. path = os.path.join(os.getcwd(), datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
  17. os.makedirs(path)
  18. ftp.dir(files.append)
  19. for log in files:
  20. print(log)
  21. filename = log.split(" ")
  22. ftp.retrbinary("RETR " + filename[len(filename) - 1], open(path + "\\" +filename[len(filename) - 1] , 'wb').write)
  23.  
  24. ftp.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement