I have the following script,
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;
use Expect;
my $logs = "logs";
open(LOG,'>>',"$logs") or die "can't logs $!\n";
my $domain = 'domain.com';
my @host = qw/host/;
foreach my $host (@host) {
my $cmd = "passwd user1";
my $sshost = join('.', $host, $domain);
my $ssh = Net::SSH::Perl->new("$sshost");
$ssh->login('root');
$ssh->debug();
my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print LOG $stdout,"\n";
}
Now my problem is I don't know how to use Expect to send the password after the $cmd
is executed and it's time to key in the password. $stdin
won't work in this case since we're using HPUX.
Appreciate any guidance and sample, reading the Expect docs don't result something for me.