Script::Remote - Exceute Your Scripts Over SSH (And Pass Data Along)


  # CASE 1: Simple case
  # Write a script first (say,
  use strict;
  print "Hello, World!\n";

  # Elesewhere, in a different file
  use Script::Remote;
  my $remote = Script::Remote->new(
    script   => '',
    hostname => '',

  #### CASE 2: With Data ####
  use strict;
  print "Hello, World from $config->{myname}\n";

    variable => 'config',
    data     => { myname => "Daisuke Maki" },


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 => '',
    hostname => ''

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 = '';
  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;




The name of the script to execute


The hostname to ssh to


The username to use for ssh


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


The full path to the remote perl executable. We use the *local machine's* value of $^X by default.


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.


List of extra ssh command line arguments


Decide what to do with the output from the ssh child. Currently we simple dump everything to STDOUT (ideas, anybody?)


Copyright (c) 2008 Daisuke Maki <>


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


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