Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Generic Broadcast SSH Launcher

by mcrose (Beadle)
on May 10, 2013 at 14:01 UTC ( #1032962=note: print w/replies, xml ) Need Help??

in reply to Generic Broadcast SSH Launcher

It looks like you're reinventing a wheel.
open my $stderr_fh, '>>', '/tmp/$host.err' or die ...; open my $stdout_fh, '>>', '/tmp/$host.log' or die ...; my $ssh = Net::OpenSSH->new($host, default_stderr_fh => $stderr_fh, default_stdout_fh => $stdout_fh); $ssh->error and die "SSH connection failed: " . $ssh->error; $ssh->scp_put("/foo/bar*", "/tmp") or die "scp failed: " . $ssh->error;

Replies are listed 'Best First'.
Re^2: Generic Broadcast SSH Launcher
by QM (Parson) on May 10, 2013 at 15:09 UTC
    OK, I see that. So it seems I can use $ssh->capture2(...).

    Are there any issues between Net::OpenSSH and Parallel::ForkManager? Or is there a better way to do this without P::FM?

    Quantum Mechanics: The dreams stuff is made of

        I've come back to this now, and tried N:O:P. It makes it very simple, here's the core of the script:
        for my $host (@hosts) { $pssh->add_host($host, user => $user); } $pssh->push('*', 'command', { stderr_to_stdout => 1 }, $cmd ); $pssh->run;

        My next problem is that I want to decorate the return from each host, to tell them apart. Perhaps something like this:

        %) -c uptime kermit fozzy kermit) 10:49:37 up 3 days, 21:38, 0 users, load average: 1.00, 1.0 +1, 1.05 fozzy) 10:49:37 up 6 days, 21:08, 0 users, load average: 1.00, 1.0 +1, 1.05

        I'm not sure how I would extend N:O:P to do this. Probably have to go back into N:O.

        See my OP for an update, as I had a D'oh moment, and realized it was that easy.

        Quantum Mechanics: The dreams stuff is made of

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032962]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-07-21 06:12 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (444 votes). Check out past polls.