Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def listDevices(username, pass, regex):
- command = "list-dev " + regex
- deviceArray = []
- connectString = "plink -ssh -l " + username + " -pw " + pass + " -P " + SshPort + " " + Server + " "" + command + """
- rawList = subprocess.check_output(connectString, shell=True)
- for line in rawList.split("rn"):
- if "" is not line:
- deviceArray.append(line)
- print deviceArray
- return deviceArray
- Server = 10.10.10.1
- SshPort = 22
- username = "test"
- pass - "password"
- regex = "rt*mdr*"
- mdrList = listDevices(username, pass, regex)
- print mdrList
- subprocess.CalledProcessError: Command 'plink -ssh -l test -pw password -P 4000 10.10.10.1 "list-dev *"' returned non-zero exit status 1
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(ip,username=username, password=password, port = 9000)
- list =["list-devices rt*"]
- command = 'n'.join(list)
- print command
- stdin,stdout,stderr = ssh.exec_command(command)
- print stdout.read()
- Traceback (most recent call last):
- File "C:/Users/xx/Scripts/Test2.py", line 31, in <module>
- stdin,stdout,stderr = ssh.exec_command(command)
- File "C:Python27paramikoclient.py", line 404, in exec_command
- chan.exec_command(command)
- File "C:Python27paramikochannel.py", line 60, in _check
- return func(self, *args, **kwds)
- File "C:Python27paramikochannel.py", line 229, in exec_command
- self._wait_for_event()
- File "C:Python27paramikochannel.py", line 1086, in _wait_for_event
- raise e
- paramiko.ssh_exception.SSHException: Channel closed.
Add Comment
Please, Sign In to add comment