Can you try it?#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; use Expect; my $host = $ARGV[0]; my $pass1 = $ARGV[1]; my $pass2 = $ARGV[2]; my $ssh = Net::OpenSSH->new($host, passwd => $pass1); $ssh->error and die "unable to connect to remote host: " . $ssh->error +; my ( $pty, $pid ) = $ssh->open2pty("sudo -kp 'configtest:' bash 2>&1") or return "failed to attempt sudo bash: $!\n"; my $expect = Expect->init($pty); $expect->expect(2, [ qr/configtest:/ => sub { my $expect =shift; $expect->send($p +ass2 . "\n"); exp_continue;} ], [ qr/Sorry/ => sub { my $expect=shift; print "Failed\n"; e +xp_continue; } ], ); $expect->interact();
Which OpenSSH version and OS are you using?
In reply to Re: Losing my mind with Net::OpenSSH and Expect
by salva
in thread Losing my mind with Net::OpenSSH and Expect
by rastoboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |