how do I sent escape character ^] through a spawned telnet session?

user2840240 picture user2840240 · Oct 16, 2013 · Viewed 24.8k times · Source

I am able to open a spawned telnet session in a shell script to run some commands. Afterwards, I am trying to send the escape character using send (see syntax below) but it never gets to the part where I am able to close the session. Can someone point me in the right direction? Due to this issue, I am opening up multiple telnet sessions this way, which I do not want to do.

send "^]\r"
expect "telnet>"
send "close\r"
close $spawn_id 

Answer

glenn jackman picture glenn jackman · Oct 16, 2013

You send the ESC control sequence. Try send "\x1b\r"