Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Getting variable sized reapones using Net::SSH2

by Illuminatus (Curate)
on Sep 06, 2012 at 17:58 UTC ( #992158=note: print w/replies, xml ) Need Help??

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.


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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992158]
jkva dusts the floor
[karlgoethebier]: Totally OT but my pleasure: Next week i'll have my first archery lesson.
[Corion]: Hi jkva!
[Corion]: karlgoethevier: Oooh, that sounds interesting! ;)
[karlgoethebier]: btw, good morning
[Happy-the-monk]: karlgoethebier: have fun! Did some archery at the age of 14 or so.
[karlgoethebier]: Corion: It is, indeed.
[Happy-the-monk]: even more OT: received the complete series of Robin Hood/Robin of Sherwood 1984 on used dvds this morning :)
[Happy-the-monk]: (purely coincidental)
[jkva]: Corion Hey there :)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2017-10-20 09:56 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (260 votes). Check out past polls.