Thursday, September 10, 2020

Netmiko Cisco Question

Just got my first netmiko script working. Very basic, just gives me the interface status for one switch

from netmiko import ConnectHandler cat3750x = { "device_type" : "cisco_ios", "ip": "x.x.x.x" "username" : "user" "password" : "password" "secret" : "password" } net_connect = ConnectHandler(**cat3750x) net_connect.enable() output = net_connect.send_command("show interface status") print (output) 

So this works good for one switch. But I have about 70 switches i need to hit. I already have a file called "hosts.txt" with a list of all the IPs I want to hit. What can I add to this so that the script looks at a file called "hosts.txt" and hits every switch on that list with the commands?



No comments:

Post a Comment