[英]Exit from file of commands with Netmiko
I have a problem in my Python script because I send command from my file text.txt
to my Cisco router but I don't have the possibility to exit from the command line.我的 Python 脚本有问题,因为我将文件
text.txt
中的命令发送到我的 Cisco 路由器,但我无法从命令行退出。
Python code: Python代码:
device.config_mode()
device.send_config_from_file(config_file="text.txt")
device.exit_config_mode()
text.txt文本.txt
interface loopback 10.10.10.10
description LO
ip adress 10.10.10.10 255.255.255.0
exit
vrf definition VRF 10
description vrf
...
The exit
command does not work. exit
命令不起作用。
you can use these config:你可以使用这些配置:
from netmiko import ConnectHandler
from getpass import getpass
cisco_Router = {
"device_type": "cisco_ios",
"host": "IPaddress",
"username": "username",
"password": "password",
"secret": "enable_password"}
with ConnectHandler(**cisco_Router) as net_connect:
net_connect.enable()
output = net_connect.send_config_from_file('config_file.txt')
net_connect.disconnect()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.