Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I unable to judge weather the script actually succeeded in connecting the host and failed only in executing the the command which I have assigned for $cmd.

Yes, I think the connection has succeeded and the error is coming from the Linux host - though I doubt very much that "pwd" is in fact unknown to that host.

On Windows, I'm apparently not set-up to use the auth_keyboard authentication to my remote Linux host - instead of auth_keyboard, I use auth_pubkey.
Then, in order to get your script to work, I have to slightly alter your run_testsuite() sub to:
sub run_testsuite { my $cmd = $_[0]; my $ssh2 = $_[1]; my $chan2 = $ssh2->channel(); #$chan2->blocking(0); $chan2->exec($cmd); print "LINE : $_" while <$chan2>; $chan2->close; return 0; }
Update: Actually, your original sub works fine for me so long as I precede the call to $chan2->shell(); with $chan2->blocking(0); .

With $ssh2->debug(0), that outputs (as expected):
Executing command... ==> Running pwd LINE : /home/sisyphus test passed done 0


Maybe give that approach a go instead - if only to verify that your remote Linux host does understand "pwd".

With $ssh2->debug(1) it outputs:
Executing command... ==> Running pwd Net::SSH2::poll: timeout = 1000, array[0] libssh2_channel_open_ex(ss->session, mandatory_type, strlen(mandatory_ +type), window_size, packet_size, ((void *)0) , 0 ) -> 0x2a6e3c4 Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::getc(ext = 0) LINE : /home/sisyphus Net::SSH2::Channel::DESTROY test passed done 0 Net::SSH2::DESTROY object 0x297d73c
which is also quite correct, but confusingly verbose.

If I include $chan2->blocking(0); (presently commented out), the debugging output becomes a little less verbose:
Executing command... ==> Running pwd Net::SSH2::poll: timeout = 1000, array[0] libssh2_channel_open_ex(ss->session, mandatory_type, strlen(mandatory_ +type), window_size, packet_size, ((void *)0) , 0 ) -> 0x29ce3c4 Net::SSH2::Channel::getc(ext = 0) Net::SSH2::Channel::DESTROY test passed done 0 Net::SSH2::DESTROY object 0x28dd73c
For your script, you could try setting blocking(0) and blocking(1) to see if that makes any difference. You might also try replacing:
print $chan2 "$cmd \n";
with:
print $chan2 "$cmd\n";
And try anything else you can think of ;-)

Cheers,
Rob

In reply to Re: Problem in connecting to remote unix host via Net::SSH2 from windows machine by syphilis
in thread Problem in connecting to remote unix host via Net::SSH2 from windows machine by Perl_abcd_monk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found