Скрипт Python для устройств Cisco [закрыто]Python

Программы на Python
Anonymous
Скрипт Python для устройств Cisco [закрыто]

Сообщение Anonymous »

Я хочу извлечь запущенную конфигурацию с устройств Cisco, но не получить желаемый результат из кода
#import the neccessary modules
import time, sys, getpass, paramiko

#setup the variables used in the script
ip = '10.155.111.5'
username = ""
password = ""

#establish an SSH session using local authentication to a cisco switch
remote_conn_pre = paramiko.SSHClient()
remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
remote_conn_pre.connect(ip, username=username, password=password,
look_for_keys= False, allow_agent=False)
print "Interactive SSH session established to %s" %ip
remote_conn = remote_conn_pre.invoke_shell()
output = remote_conn.recv(1000)
print output

#check current settings on SNMP
remote_conn.send("show run | in snmp")

#display the updated port config
output = remote_conn.recv(3000)
print "-------------------AFTER-----------------------"
print '\n'.join(output)

#close out ssh session
sys.exit("ALL Done!")

Получение следующего вывода
>>>
====================== RESTART: D:\user\SNMP.py ======================
Interactive SSH session established to 10.155.111.5

switch003#
-------------------AFTER-----------------------
s
>>>

Вернуться в «Python»