Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import sys
  2. import telnetlib
  3.  
  4. #Read the ip address from the router
  5. host = open("ips.txt","r")
  6.  
  7.  
  8.  
  9.  
  10. def telnet(host):
  11.  
  12. #My user and password
  13. user="test"
  14. password="teste"
  15. #essa variavel aqui é para poder criar o arquivo de backup com o ip do equipamento
  16. backupfile = host
  17.  
  18.  
  19. tn= telnetlib.Telnet(host)
  20. tn.read.until("Username")
  21. tn.write(user+"\n")
  22. tn.read.until("Password")
  23. tn.write(password+"\n")
  24. #Cisco commands to do the backup
  25. tn.write("enable\n")
  26. tn.write("cisco\n")
  27. tn.write("terminal length 0\n")
  28. tn.write("show running\n")
  29. tn;wrote("exit\n")
  30. #Creating the file
  31. out = tn.read_all()
  32. file=open("backupfile.txt","w")
  33. file.write(out)
  34. file.close()
  35. tn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement