Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Net::SSH::Perl doesn't like long commands

by salva (Canon)
on Jun 10, 2013 at 12:14 UTC ( [id://1038054]=note: print w/replies, xml ) Need Help??


in reply to Net::SSH::Perl doesn't like long commands

This looks like a bug on Net::SSH::Perl.

I can reproduce the problem myself. In my environment, Net::SSH::Perl hangs at some point between 8000 and 10000 characters.

Net::OpenSSH can handle the same commands without any issue (that's why I think the problem lies on Net::SSH::Perl):

#!/usr/bin/perl use strict; use Net::OpenSSH; use Net::SSH::Perl; my $host = $ARGV[0] // "localhost"; for my $len (10, 100, 1000, 2000, 4000, 6000, 8000, 10000, 20000, 5000 +0) { my $cmd = "echo "; $cmd .= "." x $len; warn "trying with Net::OpenSSH, len=$len...\n"; my $ssh1 = Net::OpenSSH->new($host); my ($stdout1, $stderr1) = $ssh1->capture($cmd) or die "Failed!\n"; warn "Failed $?!\n" if $?; warn "trying with Net::SSH::Perl, len=$len...\n"; my $ssh2 = Net::SSH::Perl->new( $host, # debug => 1, options => [ "BatchMode yes", "PasswordAuthenticati +on no", "ConnectTimeout 15" ] + ); $ssh2->login("root") or die "Failed to login: $!\n"; warn "logged\n"; my ($stdout2, $stderr2, $exit) = $ssh2->cmd($cmd); warn "Failed $exit!\n" if $exit; }

Replies are listed 'Best First'.
Re^2: Net::SSH::Perl doesn't like long commands
by BrowserUk (Patriarch) on Jun 10, 2013 at 12:23 UTC
    hangs at some point between 8000 and 10000 characters.

    What's the betting that it is somewhere around 8192, the size of PerlIO IO buffers since 5.1(2|4|?).

    Maybe someone how has reproduced it could try disabling the buffering and see if that changes anything.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I see syswrite calls in this code

      http://cpansearch.perl.org/src/SCHWIGON/Net-SSH-Perl-1.35/lib/Net/SSH/Perl/Packet.pm

      Looks like it's not protected from EAGAIN and from case when syswrite didn't write all data.

      sysread calls are protected.

      It is very unlikely that buffering may be the root of the problem because of the way the SSH protocol is internally structured in several layers. A buffering issue would have manifested itself as a wider set of problems.
      Setting $|++ doesn't help unfortunately (and the value on my boxes are different, see above... :/ ).
        Setting $|++ doesn't help

        Worth a shot as it doesn't involve a lot of effort.

        (You do know that for $|++ to affect the socket in question, it needs to be selected first?)


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1038054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found