You can use the fork method of a GRID::Machine object. (See GRID::Machine::Process)

$ cat -n fork5.pl 1 #!/usr/bin/perl -w 2 use strict; 3 use GRID::Machine; 4 use Data::Dumper; 5 6 my $host = $ENV{GRID_REMOTE_MACHINE}; 7 my $machine = GRID::Machine->new( host => $host ); 8 9 my $p = $machine->fork( q{ 10 11 print "stdout: Hello from process $$. args = (@_)\n"; 12 print STDERR "stderr: Hello from process $$\n"; 13 14 use List::Util qw{sum}; 15 return { s => sum(@_), args => [ @_ ] }; 16 }, 17 args => [ 1..4 ], 18 ); 19 20 # GRID::Machine::Process objects are overloaded 21 print "Doing something while $p is still alive ...\n" if $p; 22 23 my $r = $machine->waitpid($p); 24 25 print "Result from process '$p': ",Dumper($r),"\n"; 26 print "GRID::Machine::Process::Result objects are overloaded i +n a string context:\n$r\n";
When executed, the former program produces an output similar to this:

$ perl fork5.pl Doing something while 5220:5230:some.machine:5234:5237 is still aliv +e ... Result from process '5220:5230:some.machine:5234:5237': $VAR1 = bles +s( { 'machineID' => 0, 'stderr' => 'stderr: Hello from process 5237 ', 'descriptor' => 'some.machine:5234:5237', 'status' => 0, 'waitpid' => 5237, 'errmsg' => '', 'stdout' => 'stdout: Hello from process 5237. args += (1 2 3 4) ', 'results' => [ { 'args' => [ 1, 2, 3, 4 ], 's' => 1 +0 } ] }, 'GRID::Machine::Process::Result' ); GRID::Machine::Process::Result objects are overloaded in a string co +ntext: stdout: Hello from process 5237. args = (1 2 3 4) stderr: Hello from process 5237
The fork method returns a GRID::Machine::Process object. The first argument must be a string containing the code that will be executed by the forked process in the remote machine. Such code is always called in a list context.

In reply to Re: Parallel SSH by casiano
in thread Parallel SSH by solaris7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.