FAQ
I'm going into a "while" loop with a list of servers and need to execute a
remote command and bring back the output. Doing a "qx/remsh <server name>
<my script/;" doesn't bring back the output. I'm sure this can be done but
how?

Don Dukelow

Search Discussions

  • Igor Sutton at Dec 20, 2006 at 4:49 pm
    2006/12/20, Dukelow, Don <don.dukelow@hp.com>:
    I'm going into a "while" loop with a list of servers and need to execute a
    remote command and bring back the output. Doing a "qx/remsh <server name>
    <my script/;" doesn't bring back the output. I'm sure this can be done
    but
    how?

    Don Dukelow

    What about pipe'ing the output of your program to Perl? Check the (untested)
    code below.

    <code>
    foreach my $host (@hosts) {
    open my $remsh, "remsh $host < script |" or die $!;
    my $output;
    {
    local $/;
    $output = <$remsh>;
    }
    print "$output";
    close $remsh or warn $!;
    }
    </code>

    You also has the option to use a secure shell instead, and then
    Net::SSH::Perl[1] comes to rescue you.

    [1] http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm

    Hope this helps!

    --
    Igor Sutton Lopes <igor.sutton@gmail.com>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedDec 20, '06 at 3:57p
activeDec 20, '06 at 4:49p
posts2
users2
websiteperl.org

2 users in discussion

Igor Sutton: 1 post Dukelow, Don: 1 post

People

Translate

site design / logo © 2022 Grokbase