Telnetlib and special quit characters with Ctrl, oh my!

winona_whitener at winona_whitener at
Wed Dec 19 15:28:57 CET 2012

Greetings all,

I am using telnetlib and the box that I'm connecting to has a special escape sequence--^]--to leave the prompt and go back to the regular telnet prompt.  For example, from teh command line I do this:

Login:> xxxxxx
Password:> xxxxxxx

Connected to ''.
Escape character is '^]'.

#> (some commands)

When I pressing and hold Ctrl and then ], I go back to my normal telnet prompt and can quit.

Using telnetlib, I can send commands and get responses.  But I'm stuck on sending the ctrl+]!  Is there some escape character--\c?--or a keycode like \^ to send through telnetlib?

Telnetlib is doing what I need it to, but the read_until command that I'm familiar appears to be getting stuck on the fact that I never leave the connection properly--like I would normally do with an "exit" or "quit".

As always, I'm glad for comments and pointers in the right direction!

Thank you all in advance,

More information about the Python-list mailing list