Here is the code I use under cygwin or linux redhat
— # connect $ssh2->connect($remote_server) or die "\nERROR02 - Unable to connect H +ost $@ \n"; ($code, $error_name, $error_string) = $ssh2->error(); if ($code ne 0) { &log("error001","code = $code"); &log("error002","error_name = $error_name"); &log("error003","error_string = $error_string"); } if ($ssh_pattern eq '/passphrase/') { # authenticate with key and passphrase $ssh2->auth_publickey($remote_login, $pub_key_file, $priv_key_file +, $remote_password) or die "\nERROR03 Unable to login $@ \n"; ($code, $error_name, $error_string) = $ssh2->error(); if ($code ne 0) { &log("error011","code = $code"); &log("error012","error_name = $error_name"); &log("error013","error_string = $error_string"); } } else { # authenticate with user and password $ssh2->auth_password($remote_login,$remote_password) or die "\nERR +OR04 Unable to login $@ \n"; ($code, $error_name, $error_string) = $ssh2->error(); if ($code ne 0) { &log("error021","code = $code"); &log("error022","error_name = $error_name"); &log("error023","error_string = $error_string"); } } # DE-Block SSH2 for channel open (blocking to 1) $ssh2->blocking(1); # open channel 1 $chan1 = $ssh2->channel(); ($code, $error_name, $error_string) = $ssh2->error(); if ($code ne 0) { &log("error031","code = $code"); &log("error032","error_name = $error_name"); &log("error033","error_string = $error_string"); } # Block SSH2 for channel shell (blocking to 0) $ssh2->blocking(0); ($code, $error_name, $error_string) = $ssh2->error(); if ($code ne 0) { &log("error051","code = $code"); &log("error052","error_name = $error_name"); &log("error053","error_string = $error_string"); } # start channel shell $chan1->shell(); # send a CR to initialize the session print $chan1 "\n";
Regards Charles.

In reply to Re^3: Net::SSH2::Channel with exec, reads 0 bytes on suse while works fine on ubuntu by Anonymous Monk
in thread Net::SSH2::Channel with exec, reads 0 bytes on suse while works fine on ubuntu by madhurikl

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.