Telnetlib and special quit characters with Ctrl, oh my!

W

winona_whitener

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:

telnet 123.12.123.0
Login:> xxxxxx
Password:> xxxxxxx

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

#> (some commands)
(responses)

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,
newbo
 
C

Chris Angelico

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:
...
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?

The ctrl-] keystroke doesn't get sent down the wire, it's commands to
the _local_ telnet. For instance, if your session has stalled, you can
enter "^]close" to immediately disconnect. There won't be a direct way
to drop to "command mode" inside telnetlib, but you can do similar
actions with methods on the connection object (in that instance,
close() will do the job).

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top