Open3 and ssh

I’m writing an app using RubyCocoa on MacOS X 10.4.11 which i want to
implement a Pseudo-terminal connected to a remote host via ssh.

When i test ssh from command line i get the waiting prompt and escape
sequences, login and logout messages.
But, testing with ruby, ssh no more sends the waiting prompt, nor escape
sequences and even no logout message.
I think this is because ssh “sees” my UI isn’t a peudo-terminal even if
i make use of the option -T to force (?) allocation of it (before that i
got the known message “Pseudo-terminal will not be allocated because
stdin is not a terminal.”).
And because i don’t see any control characters, i think ssh “knows” my
UI isn’t a pseudo-terminal from the beginning of the connection.

I suppose i need to implement “something” but i lak info on what and how
to do it. I suspect this is at a low level (tty?).

here is my ruby code :

#! /usr/bin/env ruby

require ‘open3’

ENV[‘TERM’]=“ansi”
ansi_red="\e[31m"
ansi_clear="\e[0m"

Open3.popen3(“ssh -T TT”) { |stdin, stdout, stderr|
Thread.start do
while c=STDIN.getc
stdin.print c.chr
end
end
Thread.start do
while line=stderr.gets
puts ansi_red+line.chomp+ansi_clear
end
end
while c=stdout.getc
print c.chr
# print any not printable control char (except \n and \r)
print “*** #{c} ***” if (c<32||c>127)&&(c!=10&&c!=13)
end
}