You can execute commands on remote machines from a Perl script using the Net::SSH::Perl module.
This module allows you to execute a command remotely and receive the STDOUT, STDERR, and exit status of that remote command.
One big advantage of Net::SSH::Perl over other methods is that you can automate the login process, that way you can write fully automated perl scripts, no console interaction is required in order to authenticate in the remote machine.
Example:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;
my $host = "";
my $user = "";
my $password = "";
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd("your command");
Update:
Execution of Net::SSH::Perl commands can be quite slow if you don't have the Math::BigInt::GMP module; so be sure that you have that module installed in order to avoid the slowness problem.
Make sure that in both the Linux servers ssh enabled and server listens on port number 22.
|