Вот небольшой скрипт, который проверяет 'show interface xxx'
from netmiko import ConnectHandler
cisco = {
'device_type': 'cisco_ios',
'host': 'cisco.domain.com',
'username': 'admin',
'password': 'cisco123',
}
try:
net_connect = ConnectHandler(**cisco)
net_connect.enable()
interface =input('Pls enter the interface name: ')
output = net_connect.send_command("show interface " + interface)
print('*'*10)
print(output)
net_connect.disconnect()
except:
print(cisco['host']+' not connected!')
Как видите, это довольно просто. в основном мы отправляем строку внутри .send_command()
. Таким образом, вы можете поместить любую строку, которую хотите отправить, как показано ниже:
interface = input('Pls enter the interface name: ')
output = net_connect.send_command("show interface " + interface)