Advertisement
Guest User

Python FTPLib Example

a guest
Mar 13th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. from ftplib import FTP
  2. import io
  3. import sys
  4.  
  5. print("Please input the host address: ")
  6. ho = sys.stdin.readline(50).replace("\n", "")
  7. print("Please input the host port: ")
  8. po = sys.stdin.readline(6).replace("\n", "")
  9. print("Please input the username: ")
  10. us = sys.stdin.readline(50).replace("\n", "")
  11. print("Please input the password: ")
  12. pw = sys.stdin.readline(50).replace("\n", "")
  13.  
  14. #https://docs.python.org/3/library/ftplib.html
  15. print("Connect to %s:%s@%s:%i" % (us, pw, ho, po))
  16. ftp = FTP()         #Create FPT Object
  17. ftp.connect(ho, po) #Set the Host and Port
  18. ftp.login(us, pw)   #Connect und login the user with the pw to the host and port
  19. ftp.dir()           #Prints every given file and directory of the main folder
  20. ftp.quit()          #Disconnect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement