It's hard to explain the elation I felt when I found a working ssh module recently. I've hit a low spot though, when I attempted to take my functioning routine and wrap it up inside a list of hosts.
#!/usr/bin/perl use strict; use Net::SSH2; my $hf = 'list.txt'; my $user = 'user'; my $pass = 'pass'; my $ssh = Net::SSH2->new(); $ssh->debug(1); open (L,"<$hf") || die "$!"; while(<L>) { chomp $_; print "Connecting now..\n"; $ssh->connect("$_") || warn "$!"; $ssh->auth_password("$user","$pass"); my $chan = $ssh->channel(); $chan->exec('dir'); $chan->close(); } close L;
This was a test script I used to simplify troubleshooting, and I still got the following result:
# ./test.pl Connecting now.. libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type +, window_size, packet_size, ((void *)0) , 0 ) -> 0x841ed400 Net::SSH2::Channel::DESTROY Connecting now.. Resource temporarily unavailable at ./test.pl line 14, <L> line 2. libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type +, window_size, packet_size, ((void *)0) , 0 ) -> 0x0 Can't call method "exec" on an undefined value at ./test.pl line 21, < +L> line 2. Net::SSH2::DESTROY object 0x8663b6c0
It's the "Resource is temporarily unavailable" that I'm seeing when I don't have the debug running. I even threw in a sleep to see if that might help. The first host connects perfectly, and I can run commands, etc. That second host (which by the way IS online) fails reliably. Any suggestions?!

In reply to Net::SSH2 woes by vdubjunkie

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.