Reputation: 3669
Need a way to have a perl script running on one machine run a perl script running on another.
The remote machine config is:
Questions, feedback, comments -- just comment, thanks!!
Upvotes: 2
Views: 1024
Reputation: 140
The above answers are fine for a one-off, but if you're doing this sort of thing a lot, you may want to look into some sort of messaging system like AMPQ (e.g. RabbitMQ) and set up queue listeners.
Upvotes: 2
Reputation: 31
As @Nylon Smile mentioned, you can use system
to invoke the system's ssh client. If you want to do this without relying on external binaries (in particular because you want to handle password authentication differently), try Net::SSH::Perl
, available from CPAN.
use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new('host');
$ssh->login('username', 'password');
my ($stdout, $stderr, $exit_code) = $ssh->cmd(
'perl some_script.pl --with=some_args',
'optionally, some stdin for that script'
);
Net::SSH::Perl can be a bit of a pain to install, but there are several other CPAN modules (most of which rely on an installed OpenSSH) and are a bit easier to deal with while providing a similar api. See also Net::SSH
and Net::OpenSSH
.
Upvotes: 3
Reputation: 9446
Is this what you want?
system("ssh user@remotemachine perl <remote script's full path>");
will run the script on remote machine.
you may want to ssh without password, check: http://linuxproblem.org/art_9.html
Upvotes: 5