If you only need to run a simple command in every host, instead of
Net::SSH::Perl just use the
ssh command installed on your system:
sub mydate {
my $out = `ssh $host -i fxfer.key date 2>&1`;
print "[$id] out: $out\n";
print "[$id] exit: $?\n";
}
And if you really need stderr separated from stdout, you will have to implement it at a lower level than the backquotes (I will show you how to do it if you want).
Lately, I have been working in Net::OpenSSH that can do almost anything Net::SSH::Perl does (and much more!). It uses OpenSSH under the hood, instead of its own implementation of the Secure Shell protocol... though it is still very alpha and does not work on Windows.
Using Net::SSH2 can be another good option.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.