![]() |
safe output in a file for all switches in a network - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: safe output in a file for all switches in a network (/thread-11797.html) |
safe output in a file for all switches in a network - henry1077 - Jul-26-2018 Hello, I hope somebody can help me. I'll write a script where I get output in a text file. One command output should safed for all switches in a network. if possible in one textfile per switch. At the moment I have written following: from netmiko import ConnectHandler import sys ip1 = { "device_type":"hp_procurve", "ip": "192.168.48.254", "username":"Hendrik", "password":"test" } net_connect = ConnectHandler(**ip1) print ("Wait please") print("sh tech all will be printed in file" ) # output in Datei sh_tech.txt sys.stdout = open('sh_tech.txt', 'w') sh_tech = net_connect.send_command("sh version") print (sh_tech) # sys.stdout.close() ip1 = { "device_type":"hp_procurve", "ip": "192.168.48.2", "username":"Hendrik", "password":"test" } print ("Wait please") print("sh tech all will be printed in file" ) # output in Datei sh_tech.txt sys.stdout = open('sh_tech_192_168_48_2.txt', 'w') sh_tech = net_connect.send_command("sh tech all") print (sh_tech) sys.stdout.close()It would be better if I can enter the network for example 192.168.48.0/24 and for every switch it will be created a seperate textfile. |