Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import telnetlib
- #Read the ip address from the router
- host = open("ips.txt","r")
- def telnet(host):
- #My user and password
- user="test"
- password="teste"
- #essa variavel aqui é para poder criar o arquivo de backup com o ip do equipamento
- backupfile = host
- tn= telnetlib.Telnet(host)
- tn.read.until("Username")
- tn.write(user+"\n")
- tn.read.until("Password")
- tn.write(password+"\n")
- #Cisco commands to do the backup
- tn.write("enable\n")
- tn.write("cisco\n")
- tn.write("terminal length 0\n")
- tn.write("show running\n")
- tn;wrote("exit\n")
- #Creating the file
- out = tn.read_all()
- file=open("backupfile.txt","w")
- file.write(out)
- file.close()
- tn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement