Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telnetlib }
- def Open_telnet_connection():
- try:
- username = 'username'
- password = 'password'
- ip = 'xx.xx.xx.xx'
- port = XXXX
- reading_timeout = 5
- connection = telnetlib.Telnet (ip)
- console_output = connection.read_until ("ENTER USERNAME <", reading_timeout)
- print console_output
- connection.write (username + 'rn')
- console_output = connection.read_until ("ENTER PASSWORD <", reading_timeout)
- connection.write (password + 'rn')
- print console_output
- connection.write ("***My command to follow the process***")
- console_output = connection.read_until ("here I can put any text, I use this only to get the output", 600)
- print console_output
- connection.write('***Command instead of Ctrl-C***') ***????***
- connection.close ()
- except IOError:
- print "connection not established"
- if __name__ == '__main__':
- Open_telnet_connection ()
Add Comment
Please, Sign In to add comment