Python: SSH into Cisco device and run show commands

Python: SSH into Cisco device and run show commands


from Exscript.util.interact import read_login
from Exscript.protocols import SSH2

account = read_login()              
conn = SSH2()                       
conn.connect('192.168.1.11')     
conn.login(account)                 

conn.execute('show ip route')
print conn.response

conn.send('exitr')               
conn.close()
from Exscript.util.interact import read_login
from Exscript.protocols import SSH2

account = read_login()              
conn = SSH2()                       
conn.connect('192.168.1.11')     
conn.login(account)  

conn.execute('terminal length 0')           

conn.execute('show version')
print conn.response

conn.send('exitr')               
conn.close()
terminal length 0

No comments:

Post a Comment