Python Forum

Full Version: paramiko exit code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I would like to ask please what is the correct way to check for exit code in paramiko. For some devices when the "show version" works fine it gives exit code as 0, for other devices where also "show version" works fine it shows the exit code as 255


Example:
>>> ssh.connect(hostname, port, username, password, look_for_keys=False)
>>> stdin,stdout,stderr = ssh.exec_command('show version')
>>> Exit = (stdout.channel.recv_exit_status())
>>> ssh.close()
>>> print (Exit)
255
Here is the device output.
Output:
RP/0/0/CPU0:vPE4-XR#show version Tue Aug 20 12:38:53.982 UTC Cisco IOS XR Software, Version 5.1.3[Default] Copyright (c) 2014 by Cisco Systems, Inc.
Thanks