Advertisement
Guest User

Untitled

a guest
Dec 21st, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import telnetlib
  2. import sys
  3. import time
  4.  
  5. def open_telnet_conn(ip):
  6. username = 'python'
  7. password = 'python@18'
  8. T_port = 23
  9. T_timeout = 5
  10. R_timeout = 5
  11.  
  12. connection = telnetlib.Telnet(ip, T_port, T_timeout)
  13. output = connection.read_until(b"ogin:", R_timeout)
  14. connection.write(username.encode('ascii')+b"\n")
  15.  
  16. output = connection.read_until(b"word:", R_timeout)
  17. connection.write(password.encode('ascii')+b"\n")
  18. time.sleep(1)
  19.  
  20. connection.write(b"\n")
  21. connection.write(b"get router info routing all\n")
  22. time.sleep(1)
  23.  
  24. connection.write(b"\n")
  25. connection.write(b"exit \n")
  26. time.sleep(1)
  27.  
  28. router_output = connection.read_very_eager()
  29. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement