Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send Ctrl + a then d in Expect

Tags:

expect

So I am trying to spawn a shell to a remote server then make a screen run some commands and then detach from said screen by doing:

#!/usr/bin/expect

set server [lindex $argv 0]

spawn s "$server"
expect "#" { send "screen -S test\r" }
expect "#" { send \someescapeheretoreplicate ctrl + a then d to tell screen to detach }
interact

But I have no idea what those escape sequences are called so am unable to look up a table of them or what not.

like image 354
morissette Avatar asked Oct 16 '25 04:10

morissette


1 Answers

If I recall:

send "\x01"; send "d"

Where \x01 is the value of Ctrl-A

like image 119
glenn jackman Avatar answered Oct 19 '25 12:10

glenn jackman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!