[root@dr-mysql01 mojo]# cat a1.pl
use Net::OpenSSH;
my $host = '121.4xx.xx1.41';
my $user = 'root';
my $key = '/root/.ssh/id_rsa';
my %param = (
user => $user,
key_path => $key,
timeout => 100
);
my $ssh = Net::OpenSSH->new($host,%param);
my ($stdout,$stderr) = $ssh->capture2("$ARGV[0]");
if($stdout){
print $stdout;
} else {
print $ssh->error;
$stderr and print $stderr;
}