Monks,

I have a version of Expect 1.15 that I am attempting to use to capture input from commands such as ls -l

However, the input appears to be get chopped as I cannot see all of the files from the listing command. I have been logging the output and also checking the accumulator.

Upon inspection of the Expect module, it appears that it performs a sysread using a fixed number of bytes.

Are there any solutions to capture the full output of a command that might dump quite a bit of output to STDOUT?


Best Regards
Ty

Update:

I used the perl debugger to walk through Expect and then I came up with a solution that works

# given an Expect object in $e # given a command to run in $command # given a timeout value in $timeout # given that command does not print ENDOFCOMMAND to STDOUT $e->send("$command;echo ENDOFCOMMAND\n"); $e->expect($timeout,[qr/(?<!echo )ENDOFCOMMAND/ => sub { 0;}], [qr/(echo ENDOFCOMMAND)/ => sub { exp_continue;}]); $outputfromcommand = $e->before();


In reply to Expect Question by tmaly

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.