# Noob Problem (sending CTRL + \] )

**URL:** <https://www.ruby-forum.com/t/noob-problem-sending-ctrl/176151>\
**Category:** Ruby\
**Created:** [September 25, 2009, 10:59am UTC](https://www.ruby-forum.com/t/noob-problem-sending-ctrl/176151 "2009-09-25T10:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdesbure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sdesbure](https://www.ruby-forum.com/u/sdesbure)\
**Post date:** [September 25, 2009, 10:59am UTC](https://www.ruby-forum.com/t/noob-problem-sending-ctrl/176151/1 "2009-09-25T10:59:51Z")

</div>

Hi all,  
I want to create a script which will execute the following tasks:  
launch a console on a virtual server via libvirt:  
virsh console NameOfTheServer  
Log into the server  
login \n  
password\n  
send a command inside the server  
command  
send CTRL + ]

I’m first not sure how to send the command after sending an os command.  
and I definitely don’t know how to send the special key CTRL + ] (^])

Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![sdesbure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sdesbure](https://www.ruby-forum.com/u/sdesbure)\
**Post date:** [September 25, 2009, 2:25pm UTC](https://www.ruby-forum.com/t/noob-problem-sending-ctrl/176151/2 "2009-09-25T14:25:56Z")

</div>

Hi,

Am Freitag, 25. Sep 2009, 17:59:54 +0900 schrieb Sylvain D.:

> and I definitely don’t know how to send the special key CTRL + ] (^])  
> Ctrl-] is “\x1d”.

I don not clearly understand what you want to do but maybe this  
helps. I once wrote a tool that feeds the input queue with some  
characters before executing another process. To use it write  
something like:

fork {  
$stdin.unget “login username\rpassword verysecret\rsomecmd\r\x1d”  
exec “telnet otherhost 110”  
}

And there you are. Notice that the enter key sends “\r”, not “\n”.  
Here’s the source code:

[http://www.bertram-scharpf.de/tmp/termins.c](http://www.bertram-scharpf.de/tmp/termins.c)  
[http://www.bertram-scharpf.de/tmp/termins.h](http://www.bertram-scharpf.de/tmp/termins.h)

Bertram
