Hi Monks -
From my Linux box I'm trying to use Net::SSH::Perl to run a command on a remote Windows box running OpenSSH-3.1 and the CygWin environment. From Linux if I do 'ssh -2 -l configadm <windows ip> "/bin/ls /"', everything works perfectly, so I would think the following code should also work:
#!/usr/bin/perl -w
use Net::SSH::Perl;
use strict;
my $ip = "<windows ip>";
my $pw = "<password>";
my $user = 'configadm';
my $ssh = Net::SSH::Perl->new($ip, protocol=>2);
my ($stdout, $stderr, $exit);
eval {
$ssh->login($user,$pw);
($stdout, $stderr, $exit) = $ssh->cmd('/bin/ls /');
};
if ($@) {
die "@@@@@ failed login or command problem";
}
print $stdout;
exit 0;
The problem is that nothing ever comes back over the ssh session, so $stdout does not get populated. If I execute the same code against a unix box running openssh then everything works perfectly. So, I'm left with either a bug in Net::SSH::Perl, a bug in CygWin, or a bug in OpenSSH for windows or some combination. It works from the command line though, so where does that leave us?
--Mike
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.