问题描述
from netmiko import ConnectHandler
router = { "device_type": "xxxx","host": "xxxx","username": "xxxx","password": "xxxx",}
command = "show arp all"
net_connect= ConnectHandler(**router)
output = net_connect.send_command(command)
print(output)
有人能找出错误吗!
解决方法
我认为错误在于命令本身。命令中没有 all
。请考虑在没有 的情况下发送 show arp
show ip arp
或 all
。看看这个link。您还可以将 "session_log": "router.log"
添加到路由器的字典中,并在 router.log
文件中查找无效参数消息。
日志文件显示设备上 CLI 中发生的情况。
尝试执行以下操作:
router = {
"device_type": "xxxx","host": "xxxx","username": "xxxx","password": "xxxx","session_log": "router.log" # <--- this line
}
cmd = "show arp" # or "show ip arp"
net_connect = ConnectHandler(**router)
arp_output = net_connect.send_command(cmd)
net_connect.disconnect() # to clear the vty line when done
print(arp_output)