NAME
Script::Remote - Exceute Your Scripts Over SSH (And Pass Data Along)
SYNOPSIS
# CASE 1: Simple case
# Write a script first (say, foo.pl)
use strict;
print "Hello, World!\n";
# Elesewhere, in a different file
use Script::Remote;
my $remote = Script::Remote->new(
script => 'foo.pl',
hostname => 'some.host.com',
);
$remote->run;
#### CASE 2: With Data ####
use strict;
print "Hello, World from $config->{myname}\n";
$remote->run(
variable => 'config',
data => { myname => "Daisuke Maki" },
);
DESCRIPTION
This is a stupid little hack that makes running scripts remotely a *bit* easier.
Please note that this is full of potential security gotchas. We generate code on the fly. This is bad. We're basically doing a remote eval(), which is just bad bad bad. DO NOT USE THIS MODULE if you expect people with no or minimal knowledge about how this kind of distributed system hacks work.
Having said that, for tests, this could be handy. All you need is a ssh-enabled set of machines (you probably want public key auth, too), and two scripts: the script you want to run remotely, and a script that will drive those script(s).
To run a single script on a single remote machine, simply say:
use Script::Remote;
Script::Remote->new(
script => 'foo.pl',
hostname => 'my.host.name'
)->run();
If you want to run the same script on multiple hosts, you need to tell Script::Remote to not block on wait(), so you need to use the no_wait parameter:
my $script = 'foo.pl';
my @scripts;
my $data = ...; # some shared data
foreach my $host (@hosts) {
my $remote = Script::Remote->new(
script => $script,
hostname => $host,
no_wait => 1,
);
$remote->run(data => $data);
push @scripts, $remote;
}
$_->wait_child for @scripts;
METHODS
new
- script
-
The name of the script to execute
- hostname
-
The hostname to ssh to
- username
-
The username to use for ssh
- no_wait
-
If true, the object will not block when run() is called. In that case you should use wait_child() to wait for the child process to stop
- perl
-
The full path to the remote perl executable. We use the *local machine's* value of $^X by default.
- ssh
-
An alternate path to your ssh binary. We attempt to find one by default, but if we don't, you should be setting this or $Script::Remote::DEFAULT_SSH.
- ssh_args
-
List of extra ssh command line arguments
TODO
Decide what to do with the output from the ssh child. Currently we simple dump everything to STDOUT (ideas, anybody?)
AUTHOR
Copyright (c) 2008 Daisuke Maki <daisuke@endeworks.jp>
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 311:
=back doesn't take any parameters, but you said =back 4