Hi Monks,
I need to know if there is some way to read data into buffer and mentioning the bytes to read dynamically ?
I am currently executing something like this

$chan->shell();
$chan->write("egrep -l $searchStr * 2>&1 | tee ~/myfile.txt\n");
the above can have multiple lines as output or jus a single line or nothing at all. After this I have the read call.
$chan->read($buf, 512);
here if the ouput of the egrep does not have 512 bytes, the read call waits until it reads 512.
If I make the channel as non-blocking, then the read call does not complete and I do not get the desired result stored in the file - myfile.txt
please let me know if there is a work-around for this or I am missing something ?
J

In reply to Read call in Net::SSH2::Channel by godsown

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.