I'm working with WindwosXP + ActivePerl.

Code:

#!/usr/bin/perl use Net::SSH::W32Perl; my $host = 'x.x.x.x'; my $ssh = new Net::SSH::W32Perl($host); $ssh->login('XXX', XXX); my ($out, $err, $exit) = $ssh->cmd('show vlan brief'); print $out; print $err; print $exit;

Condition 1:

Make sure the ip, username, password is correct. Result:

Use of uninitialized value $out in print at ...

Use of uninitialized value $err in print at ...

Use of uninitialized value $exit in print at ...

Condition 2:

Input the ip that dose not exsit. Result:

Can't connect to 10.17.14.184: Unknown error

Condition 3:

Make sure the ip is ok but the username is wrong. Result:

Permission denied at ...

My guess is: the conenct and login part is ok but I just could not figure out why I can not get the result from the cmd function

Any help would be great, thanks in advance.

I tried the debug mode and here is the new code and output

#!/usr/bin/perl use Net::SSH::W32Perl; $ENV{HOME} = "C:\\"; my $host = '10.167.14.126'; my $ssh = new Net::SSH::W32Perl($host,debug=>1); $ssh->login('xxx', 'xxx'); my $out = $ssh->cmd('ll'); print $out;

Debug output:

Mike: Reading configuration data C:\/.ssh/config Mike: Reading configuration data /etc/ssh_config Mike: Connecting to 10.167.14.126, port 22. Mike: Socket created, turning on blocking... Mike: Remote protocol version 2.0, remote software version OpenSSH_4.3 Mike: Net::SSH::Perl Version 1.34, protocol version 2.0. Mike: No compat match: OpenSSH_4.3. Mike: Connection established. Mike: Sent key-exchange init (KEXINIT), wait response. Mike: Algorithms, c->s: 3des-cbc hmac-sha1 none Mike: Algorithms, s->c: 3des-cbc hmac-sha1 none Mike: Entering Diffie-Hellman Group 1 key exchange. Mike: Sent DH public key, waiting for reply. Mike: Received host key, type 'ssh-dss'. Mike: Host '10.167.14.126' is known and matches the host key. Mike: Computing shared secret key. Mike: Verifying server signature. Mike: Waiting for NEWKEYS message. Mike: Send NEWKEYS. Mike: Enabling encryption/MAC/compression. Mike: Sending request for user-authentication service. Mike: Service accepted: ssh-userauth. Mike: Trying empty user-authentication request. Mike: Authentication methods that can continue: publickey,gssapi-with- +mic,password. Mike: Next method to try is publickey. Mike: Next method to try is password. Mike: Trying password authentication. Mike: Login completed, opening dummy shell channel. Mike: channel 0: new [client-session] Mike: Requesting channel_open for channel 0. Mike: channel 0: open confirm rwindow 0 rmax 32768 Mike: Got channel open confirmation, requesting shell. Mike: Requesting service shell on channel 0. Mike: channel 1: new [client-session] Mike: Requesting channel_open for channel 1. sxcMike: Entering interactive session. Mike: Sending command: ll Mike: Sending command: ll (<==== why twice?) Mike: Requesting service exec on channel 1. Mike: channel 1: open confirm rwindow 0 rmax 32768 (<==== hangs her +e, no return)

In reply to Net::SSH::W32Perl cmd no return ??? by SuperSu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.