Code extracted from here!use Net::OpenSSH; use Expect; my $ssh = Net::OpenSSH->new($host, password => $password); my ($pty, $pid) = $ssh->open2pty("sudo cat /etc/shadow") or die "open2pty failed: " . $ssh->error . "\n"; my $expect = Expect->init($pty); $expect->raw_pty(1); # $expect->log_user(1); $expect->expect($timeout, ':') or die "expect failed\n"; $expect->send("$password\n"); $expect->expect($timeout, "\n") or die "bad password\n"; while(<$pty>) { print "$. $_" }
In reply to Re: Net::SSH2 with pty
by salva
in thread Net::SSH2 with pty
by kmitchellwr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |