Home | Mirror | Search

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