Advertisement
Guest User

Untitled

a guest
Dec 31st, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import os
  2. from netmiko import ConnectHandler
  3. import sys
  4. import time
  5. import getpass
  6.  
  7. platform = 'cisco_ios'
  8. username = raw_input("Username?:")
  9. password = getpass.getpass(prompt="Password?:")
  10. port = 4000
  11. data = open("hosts.txt")
  12. for line in data:
  13. try:
  14. device = ConnectHandler(device_type=platform, ip=line.strip(), username=username, password=password, port=port, secret=password)
  15. device.enable()
  16. output = device.send_command_timing('wr mem')
  17. if 'Version' in output:
  18. output = device.send_command_timing("\r\n")
  19. #print line
  20. print output
  21. #print output2
  22. f = open("wrmem.txt", 'a')
  23. f.write(str(line + output + "\n"))
  24. #f.write(str(output))
  25. except:
  26. continue # Basically, ignore the error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement