Guest User

Untitled

a guest
Jan 30th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import telnetlib }
  2.  
  3. def Open_telnet_connection():
  4.  
  5. try:
  6. username = 'username'
  7. password = 'password'
  8. ip = 'xx.xx.xx.xx'
  9. port = XXXX
  10.  
  11. reading_timeout = 5
  12.  
  13. connection = telnetlib.Telnet (ip)
  14.  
  15. console_output = connection.read_until ("ENTER USERNAME <", reading_timeout)
  16. print console_output
  17. connection.write (username + 'rn')
  18.  
  19. console_output = connection.read_until ("ENTER PASSWORD <", reading_timeout)
  20. connection.write (password + 'rn')
  21. print console_output
  22.  
  23. connection.write ("***My command to follow the process***")
  24. console_output = connection.read_until ("here I can put any text, I use this only to get the output", 600)
  25. print console_output
  26.  
  27. connection.write('***Command instead of Ctrl-C***') ***????***
  28.  
  29. connection.close ()
  30. except IOError:
  31. print "connection not established"
  32.  
  33. if __name__ == '__main__':
  34. Open_telnet_connection ()
Add Comment
Please, Sign In to add comment