cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Network Automation Solution : How to save configuration file of Cisco Router/Switch devices using Python Script

2408
Views
5
Helpful
1
Comments

import netmiko
from netmiko import ConnectHandler
device = ConnectHandler(device_type="cisco_ios", ip="DEVICE IP", username="USERNAME", password="PASSWORD")
output1 = device.send_command("show running-config")
save_file = open("Switch_running.txt","w")
save_file.write(output1)
save_file.close()
device.disconnect()

#python#automation#

Comments
Cisco Employee

Working command is below:

 

from netmiko import ConnectHandler

iou1 = {
'device_type': 'cisco_ios',
'ip': '172.16.221.106',
'username': 'admin',
'password': 'cisco',
}

device = ConnectHandler(**iou1)

output1 = device.send_command("show running-config")
save_file = open("Switch_running.txt","w")
save_file.write(output1)
save_file.close()
device.disconnect()