http://qs321.pair.com?node_id=992158


in reply to Getting variable sized reapones using Net::SSH2

It seems that the read method is exact; if you're blocking, then it will wait for as many chars as you ask for. There is an undocumented method in Channel called READLINE. Changing your last 3 lines thusly:
my @buf; print $chan2 ("ls -l\n"); @buf = $chan2->READLINE(); print @buf;
and keeping the buflen large (at 10K) gave me the results without hanging.

fnord

Replies are listed 'Best First'.
Re^2: Getting variable sized reapones using Net::SSH2
by essej1 (Novice) on Sep 06, 2012 at 20:17 UTC

    Thanks. It works like a champ. Got to love undocumented features. While messing around I also found this may also work. I think your's is probably better.

    print $chan2 "\ndir\n"; while (<$chan2>) { print "$_"; }
    Paradise: Florida, full tank of gas, no appointments.