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; }

In reply to Re: Net::SSH::Perl doesn't like long commands by salva
in thread Net::SSH::Perl doesn't like long commands by pattyj

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.