#! /usr/bin/perl -w use strict; use Net::SSH::Perl; use Term::ReadKey; my $host = '10.0.0.254'; my $user = 'foo'; my $pw = 'bar'; my $ssh = Net::SSH::Perl->new( $host, ( protocol => '1', debug => 1, )) or die "Could not create Net::SSH::Perl object: $!\n"; $ssh->login($user, $pw); if( @ARGV ) { ReadMode('raw'); $ssh->shell; ReadMode('restore'); } else { my($stdout, $stderr, $exit) = $ssh->cmd("get config\n"); print <<"SSH_END"; STDOUT BEGIN $stdout STDOUT END STDERR BEGIN $stderr STDERR END EXIT=$exit SSH_END }