Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Generic Broadcast SSH Launcher

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


in reply to Generic Broadcast SSH Launcher

It looks like you're reinventing a wheel. https://metacpan.org/module/SALVA/Net-OpenSSH-0.60/lib/Net/OpenSSH.pm
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?

    -QM
    --
    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:

        %) net.pl -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.

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1032962]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 00:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found