Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

6.10. Net::SSH::Expect

cpan install Net::SSH::Expect
		
		
#!/usr/bin/perl

use strict;
use warnings;
use Net::SSH::Expect;

my $ssh = Net::SSH::Expect->new(
    host    => 'localhost',
    user    => 'someuser',
    password => 'somepassword'
);

warn "Starting SSH...";
$ssh->run_ssh();

warn "Testing login output...";
my $login_output = $ssh->login();
print " Done", "\n";

my $who = $ssh->exec('who');
print($who);

my $exp = 'who';
$exp = $ssh->get_expect();
$exp->interact();