Python Forum
safe output in a file for all switches in a network
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
safe output in a file for all switches in a network
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script for HP switches bcroombs 1 2,418 Jan-25-2022, 08:04 PM
Last Post: Larz60+
  hello everyone, I am attempting to extract lldp neighbors from Cisco switches->excel skins996 1 2,960 Nov-13-2020, 04:29 PM
Last Post: evapa8f
  identify un-managed switches in network c5244714 0 1,716 Apr-12-2020, 01:12 PM
Last Post: c5244714
  Is the paramiko's API threading safe? bsxfun 0 4,278 May-18-2018, 02:56 PM
Last Post: bsxfun

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020