Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thanks, salva, your explanation seemed to play out on my command line:

The way forward in mind was to make lexical variables of the blocking, so that the entire perl syntax could be brought to bear:

my $ssh2 = get_tiny_ssh2(); my $block1 = 0; my $block2 = 0; my $block3 = 0; my $chan = $ssh2->channel(); $chan->blocking($block1); $chan->exec('ls -la'); while (<$chan>) { print } $chan->close; #shell use my $chan2 = $ssh2->channel(); $chan2->blocking($block2); #line 21

yields

Calling Net::SSH2::Channel::readline in non-blocking mode is usually a + programming error at ./5.ssh2_1.pl line 16. Can't call method "blocking" on an undefined value at ./5.ssh2_1.pl li +ne 21. $

It seems to be the next blocking call in analogous fashion that draws an error. As this is described by a flag, ergo one or zero as the logical values we all know, it shouldn't take a whole lot of effort to enumerate the possibilities.

It helps me to get a feel for the software to run it with different values. There's a little something learned with each failure:

Can't call method "error" on an undefined value at /usr/local/share/pe +rl/5.26.1/Net/SFTP/Foreign/Backend/Net_SSH2.pm line 43. $ cat 5.ssh2_1.pl ... my $block1 = 1; my $block2 = 1; my $block3 = 0; my $chan = $ssh2->channel(); $chan->blocking($block1); $chan->exec('ls -la'); while (<$chan>) { print } $chan->close; #shell use my $chan2 = $ssh2->channel(); $chan2->blocking($block2); $chan2->shell(); print $chan2 "uname -a\n"; print "LINE : $_" while <$chan2>; $chan2->close; say "execution goes through here"; my $chan3 = $ssh2->channel(); $chan3->blocking($block3); ##line 43 $chan3->exec('pwd'); while (<$chan>) { print } $chan3->close;

But after a while you realize, gosh, I'm getting blocked no matter what I do with calls to 3 different channels. Some things happen; some don't:

drwxr-xr-x 2 u61210220 ftpusers 61 Jun 9 2011 zen libssh2_channel_open_ex(ss->session, mandatory_type, strlen(mandatory_ +type), window_size, packet_size, ((void *)0) , 0 ) -> 0x0 Can't call method "blocking" on an undefined value at ./6.ssh2_1.pl li +ne 23. Net::SSH2::Channel::DESTROY Net::SSH2::DESTROY object 0xbd630ac0 $

With debug set to one, I'm reading something here, but

Net::SSH2::Channel::read(size = 4, ext = 0) - read 4 bytes - read 4 total Net::SSH2::Channel::read(size = 150, ext = 0) - read 150 bytes - read 150 total Net::SSH2::Channel::read(size = 4, ext = 0) - read 4 bytes - read 4 total Net::SSH2::Channel::read(size = 29, ext = 0) - read 29 bytes - read 29 total Can't call method "read" on an undefined value at ./5.ssh2_1.pl line 4 +2. Net::SSH2::Channel::DESTROY Net::SSH2::Channel::DESTROY Net::SSH2::Channel::DESTROY Net::SSH2::Channel::DESTROY Net::SSH2::DESTROY object 0xc71e2800

What I find revealing here is that all the channels are destroyed at the very end. Those close calls aren't doing a thing. I tried changing up the blocking scheme:

my $block1 = 1; my $block2 = 1; my $block3 = 1; my $chan = $ssh2->channel(); $chan->blocking($block1); $chan->exec('ls -la'); while (<$chan>) { print } $block1 = 0; $chan->blocking($block1); $chan->close;

This draws an error:

Can't call method "blocking" on an undefined value at ./6.ssh2_1.pl line 23.

It seems there are several threads that go like mine here, where there is little resolution for the difficulties attending to using this particular SSH2 implementation as of this writing. I am well aware that many of the peripheral software changes in perl happen at the hands of people who are much better at it than me, and like me, volunteer their time to promote open source solutions. It's one thing I like about perl so much. (I'm so glad that I left FORTRAN for C, and c for perl.) There's nothing stopping anyone from calling all those libraries we knew. P.J. Plauger was kind enough to share his source with me for _The Standard C Library_, where the math library was good enough for the time. But what with the newer ones just off the griddle? The math gets a lot harder in contemporary encryption scenarios.

I have more imaginative failures to post and found errors in my script, but I just felt successfully blocked, even when I tried to lower the number of channels to one. Either there is some hobgoblin sitting on my router that prevents ssh2 whilst allowing facebook, or I think I can say that I was unable to use this library.

I see downthread that you suggested an alternative, which I will try. Thx for the informative write-up.


In reply to Re^3: using SSH2 backend by Aldebaran
in thread using SSH2 backend by Aldebaran

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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (2)
    As of 2019-12-07 01:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Strict and warnings: which comes first?



      Results (160 votes). Check out past polls.

      Notices?