so I m very new to python I have a devices.txt file that includes all the IPs and nothing else (ex 10.10.10.1, 10.10.10.2 etc ..) I managed to get the output I want but I cannot find a way to get the script to go through the list and save the output to a txt file so far I have
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#bypass the key missing issue
ssh.connect('10.10.10.1', username='cisco', password='xxxxxxx')
#connect to device
stdin, stdout, stderr = dssh.exec_command('sh ip route')
#execute the Cisco command on the device
output = stdout.readlines()
print(output)
#print the output on the command above
if ssh.get_transport().is_active() == True:
print('Closing Connection')
ssh.close()
#Check if the connection is still open and then close it
So yeah .. any idea how to grab the IP's from that list instead of me running manually changing the IP and running the script and ..also .. saving the output in a txt file (1 file for all the devices)
Thanks !!!