Guest User

Untitled

a guest
Oct 27th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. def listDevices(username, pass, regex):
  2. command = "list-dev " + regex
  3. deviceArray = []
  4. connectString = "plink -ssh -l " + username + " -pw " + pass + " -P " + SshPort + " " + Server + " "" + command + """
  5. rawList = subprocess.check_output(connectString, shell=True)
  6. for line in rawList.split("rn"):
  7. if "" is not line:
  8. deviceArray.append(line)
  9. print deviceArray
  10. return deviceArray
  11.  
  12. Server = 10.10.10.1
  13. SshPort = 22
  14. username = "test"
  15. pass - "password"
  16. regex = "rt*mdr*"
  17.  
  18. mdrList = listDevices(username, pass, regex)
  19. print mdrList
  20.  
  21. subprocess.CalledProcessError: Command 'plink -ssh -l test -pw password -P 4000 10.10.10.1 "list-dev *"' returned non-zero exit status 1
  22.  
  23. ssh = paramiko.SSHClient()
  24. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  25. ssh.connect(ip,username=username, password=password, port = 9000)
  26. list =["list-devices rt*"]
  27. command = 'n'.join(list)
  28. print command
  29. stdin,stdout,stderr = ssh.exec_command(command)
  30. print stdout.read()
  31.  
  32. Traceback (most recent call last):
  33. File "C:/Users/xx/Scripts/Test2.py", line 31, in <module>
  34. stdin,stdout,stderr = ssh.exec_command(command)
  35. File "C:Python27paramikoclient.py", line 404, in exec_command
  36. chan.exec_command(command)
  37. File "C:Python27paramikochannel.py", line 60, in _check
  38. return func(self, *args, **kwds)
  39. File "C:Python27paramikochannel.py", line 229, in exec_command
  40. self._wait_for_event()
  41. File "C:Python27paramikochannel.py", line 1086, in _wait_for_event
  42. raise e
  43. paramiko.ssh_exception.SSHException: Channel closed.
Add Comment
Please, Sign In to add comment