Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import os
  2. import ftplib
  3. import sys
  4.  
  5. if __name__ == "__main__":
  6. ipaddress = sys.argv[1]
  7. filename = sys.argv[2]
  8. filepathDestination = sys.argv[3]
  9. user = sys.argv[4]
  10. password = sys.argv[5]
  11. obj = filetransfer(ipaddress)
  12. value = obj.ftpPush()
  13. if value == True:
  14. ftp = ftplib.FTP(ipaddress)
  15. ftp.login(username = user,passwd = password)
  16. ext = os.path.splitext(filename)[1]
  17. if ext in (".txt"):
  18. ftp.cwd(filepathDestination)
  19. ftp.storlines("STOR " + filename, open(filename))
  20. else:
  21. ftp.storbinary("STOR " + filename, open(filename, "rb"), 1024)
  22. else:
  23. print 'Wrong IP'
  24.  
  25. Traceback (most recent call last):
  26. File "ftp.py", line 35, in <module>
  27. ftp = ftplib.FTP(ipaddress)
  28. File "/usr/lib64/python2.6/ftplib.py", line 116, in __init__
  29. self.connect(host)
  30. File "/usr/lib64/python2.6/ftplib.py", line 131, in connect
  31. self.sock = socket.create_connection((self.host, self.port), self.timeout)
  32. File "/usr/lib64/python2.6/socket.py", line 567, in create_connection
  33. raise error, msg
  34. socket.error: [Errno 111] Connection refused
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement