perl and p5-Expect

I'm using perl and p5-Expect in 8.2-Release.

Code:
#!/usr/bin/perl -w

my $command = "ssh -l $user $router

use Expect;

my $exp = new Expect;

$exp->raw_pty(1);
$exp->spawn($command) or die "Cannot spawn $command: $!\n";

$exp->expect(15, "assword:");
$exp->send("$password\n");

#
# NOTHING happens above.  But when I added this bogus line, the password 
# finally is sent.  The rest of the script isn't of much use though
#
exp->expect(1, "Bogus, just time out");
[rest of script]

If I change the sending of password to below, the sends fails.

Code:
$exp->send("$password\n") or die "sending of password failed: $!\n";

Given this log in sequence looks identical to every FAQ I've seen via Google, I'm curious what I screwed up?

I'm using perl-5.12.3, p5-Expect-1.21, p5-IO-Stty-0.03. Is there a different port I should use vs p5-Expect these days?
 
Alt said:
ssh sends "Password:" line to STDERR isnt ?

Sorry, I'm not sure I understand re "isnt"? Are you suggesting ssh (OpenSSH) uses STDERR to prompt?

The script came with some SW I'm asked to port. It's claimed that this script "always" worked with ssh. (Perhaps ssh just started using STDERR?)

Anyway, I started playing with p5-Net-OpenSSH, and am thinking about moving the script to us it. I've never touched perl until now, but it didn't take long to get that module to let me log on to the remote system. Once I'm more comfortable. I'll make the change to p5-Net-OpenSSH. But would like to get to the root cause of the initial issue.

Thanks
 
I solved this. I replaced what was original used to login, with the Net::OpenSSH perl module. Specifically p5-Net-OpenSSH via ports.
 
Back
Top