Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | 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();
		
		
comments powered by Disqus