Hmmm. Maybe this is a bug in my version of PERL (v5.6.1 on Linux). I made the following test program called "test.pl":
#!/usr/bin/perl use strict; use Expect; my $object = Expect->spawn( "bash" ) or die "Could not spawn bash shell.\n"; $object->log_stdout(0); $object->max_accum( 128 * 512 ); my $header = "Test Log Header"; $object->send( "cat test_log.txt\n" ); my ($matched_pattern_position, $error, $successfully_matching_string, $before_match, $after_match) =$object->expect( 5 , -re => $header ); if( $error ne undef ) { die "Could not find header.\n"; } my @rows = split /^/ , $after_match; printf "Found %d lines after match in file.\n", scalar( @rows );
And created the file "test_log.txt" that looks something like this:
Test Log Header 040702003113 21% 1175 1859 8239 8744 2221 0 0 4 100% 7% T 6% 040702003113 21% 1175 1859 8239 8744 2221 0 0 4 100% 7% T 6% 040702003113 21% 1175 1859 8239 8744 2221 0 0 4 100% 7% T 6% 040702003113 21% 1175 1859 8239 8744 2221 0 0 4 100% 7% T 6% 040702003113 21% 1175 1859 8239 8744 2221 0 0 4 100% 7% T 6% ...for 160 lines...
Then see the following:
Output of "wc test_log.txt": 161 2243 9776 test_log.txt Ouput of "test.pl": Found 34 lines after match in file.
So there's no ssh or any other complication, just the basic expect buffer of a cat result. Can someone else try this and confirm that it works as expected on their system?

Thanks,

Bret


In reply to Re^2: Expecting more from expect by bret.foreman
in thread Expecting more from expect by bret.foreman

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.