You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Netmiko的send_config执行Palo Alto带斜杠命令出现语法错误

问题原因及解决方案

核心问题是用错了Netmiko的执行函数:

  • netmiko_send_config 是专门用于下发配置类命令(如set、configure等修改设备配置的操作)的函数,它默认会确保设备处于配置模式,且对命令的格式校验逻辑更偏向配置命令。
  • show interface ethernet 1/1 是查看类命令,这类命令需要用 netmiko_send_command 函数执行,该函数专门用于运行查询类命令,适配所有特权模式下可执行的命令(包括带斜杠的格式)。

修正后的代码

output = nr.run(
    task=netmiko_send_command,
    command_string="show interface ethernet 1/1"
)

print_title("DEPLOYING AUTOMATED BASELINE CONFIGURATIONS")
print_result(output)

额外说明

如果你的场景需要先从配置模式退回到特权模式(比如之前的操作停留在配置模式),可以分两步执行命令:

# 先退出配置模式
nr.run(task=netmiko_send_command, command_string="exit")
# 再执行查看命令
output = nr.run(task=netmiko_send_command, command_string="show interface ethernet 1/1")

print_title("DEPLOYING AUTOMATED BASELINE CONFIGURATIONS")
print_result(output)

内容的提问来源于stack exchange,提问作者Super MaxLv4

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 04:50:23