@ 191120.2

190723.4 · ae666b6f6098acb702cbd2718280a61616e56d0d

Create Backup_Switch_configurations

reading declarations

Changes to Backup_Switch_configurations. All files

Backup_Switch_configurations

new file mode 100644@@ -0,0 +1,37 @@+#!/usr/bin/env python++import getpass+import telnetlib++## ASK for username and password ++user = raw_input("Enter your telent username: ")+password = getpass.getpass()++## OPEN a file called myswitches+f = open('myswitches')+++## Telent to switches and get the running config+for line in f:+	print "Getting running config from Switch " + (line)+	HOST = line.strip()+	tn = telnetlib.Telnet(HOST)+	+	tn.read_until("Username: ")+	tn.write(user + "\n")+	if password:+	    tn.read_until("Password: )+		tn.write(password + "\n")+		+	tn.write("terminal length 0\n")+	tn.write("show run\n")+  tn.write("exit\n")+  +	readoutput = tn.read_all()+  saveoutput = open("switch" + HOST, "w")+  saveoutput.write(readoutput)+  saveoutput.close+	+		+f.close()