Emulating an ANSI terminal?

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

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

ssh=IO.popen(“ssh -p 2222 [email protected]#{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 :

while(line=ssh.gets) do
break if /END_OF_COMMAND/===line

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.