For some reason, if we start ssh directly, ssh doesn't accept these ptys (and tries to launch ssh askpass). But if we start bash first, and from there launch ssh, it works.
my $h = start ['bash'], '<pty<', \$in, '>pty>', \$outAndErr, timeo
+ut(15);
pump $h until $outAndErr =~ /$prompt/;
$outAndErr='';
$in .= "ssh user\@host\n";
pump $h until $outAndErr =~ /password:/;
$outAndErr='';
$in .= "password\n";
pump $h until $outAndErr =~ /$remotePrompt/;
$outAndErr='';
# You're in - do your stuff
Disclaimer: The original version of the above snippet works, but I've simplified it for this posting, and it is possible there are (minor) bugs in the above.
|