Home | Mirror | Search | 雜文 | ITEYE 博客 | OSChina 博客 | 51CTO 博客

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