# Emulating an ANSI terminal?

**URL:** <https://www.ruby-forum.com/t/emulating-an-ansi-terminal/146142>\
**Category:** Ruby\
**Created:** [August 18, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/emulating-an-ansi-terminal/146142 "2008-08-18T13:46:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Une\_BSSSSvS\_ue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/2acd7d/32.png) [@Une\_BSSSSvS\_ue](https://www.ruby-forum.com/u/Une_BSSSSvS_ue)\
**Post date:** [August 18, 2008, 1:46pm UTC](https://www.ruby-forum.com/t/emulating-an-ansi-terminal/146142/1 "2008-08-18T13:46:23Z")

</div>

I’d like to emulate an ANSI terminal from Ruby[Cocoa] using ssh.  
Do you know of gem helper for that purpose ?

For the time being, I’m able to emulate a pseudo-terminal connection  
even if ssh answers :  
Pseudo-terminal will not be allocated because stdin is not a terminal.

However, when executing a remote command, i never knows when the answer  
ended.

I’ve found some kind of workaround executing another command, like that:

ssh=IO.popen(“ssh -p 2222 root@#{TT\_IP} 2\>&1”,“r+”)  
ssh.puts aCommand  
sleep 0.1  
ssh.puts “echo END\_OF\_COMMAND”

then, from “END\_OF\_COMMAND” i know when to stop #gets :

output=[]  
while(line=ssh.gets) do  
break if /END\_OF\_COMMAND/===line  
output\<\<line.chomp  
end

that’s working fine for ssh but not for ssh-agent and/or ssh-add, and  
I’d like to authentify using ssh-add from UI.

Notice i know how to do that from command line, but not from UI.
