【问题标题】:Netmiko : connecting to a router, Invalid parameter ^Netmiko:连接到路由器,参数无效^
【发布时间】:2021-08-04 20:41:27
【问题描述】:

我正在尝试连接到路由器并仅获得一个命令的结果,代码如下:

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)

我得到这个错误'错误:无效参数^'我不明白问题出在哪里!

有人可以找出错误吗!

【问题讨论】:

    标签: networking automation cisco netmiko


    【解决方案1】:

    我认为错误出在命令本身。命令中没有all。请考虑发送show arpshow 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 1970-01-01
      相关资源
      最近更新 更多