我正在尝试执行以下代码,以获取Cisco c3560交换机上“ show logging”命令的打印输出:
#!/usr/bin/env python3
import json
from netmiko import ConnectHandler
import datetime
now = datetime.datetime.now()
time_now = now.strftime("%b %d")
with open("home_devices.json") as d:
devices = json.load(d)
device = devices['SW_3560']
# Establish an SSH session to device
net_connect = ConnectHandler(**device)
cmd = 'show logging'
# Send Command
output = net_connect.send_command(cmd)
print(output)
# close ssh connection
net_connect.disconnect()
我得到的输出是:
C:\Python3x\python.exe C:/Users/daquezada/Dropbox/python/Net_Auto/int_handler.py
^
% Invalid input detected at '^' marker.
Process finished with exit code 0
但是另一个命令(即“ show ip int br”)运行没有问题。
请告知。
答案 0 :(得分:0)
我相信“ show logging”命令是特权EXEC命令。因此,您必须先使用“启用”命令进入EXEC模式。