It may not be a very wise solution but this is what I did: in case there is <timeout> duration of inactivity, establish a duplicate connection and check in the process table whether the concerned process is still executing. If yes, do not return from read_all() because my thinking was you have not really read all.

And I am passing an extra optional max-timeout parameter to the Net::SSH::Expect::exec() which acts as a check in the loop in read_all() in case the command hangs or something.

Update: The optional max-timeout parameter serves another purpose of circumventing a flaw in the inactivity logic of read_all(). What if a command keeps on printing stuff to its STDOUT indefinitely? The default read_all() will never return in such a case.


In reply to Re^3: Connection Failing for unknown reason by laminee
in thread Connection Failing for unknown reason by sierpinski

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.