I'm admittedly a perl novice, and I am trying figure out how to use the expect.pm module. I've never used expect in any form previously. I can see that expect is trying to match my pattern, but it doesn't appear to work, not sure what I am missing. Any help would be great!

Code snippet
my $match = 'Do you want to unpack these archive files for processing? + [Y/N]: '; #my $exp = Expect->spawn($command, $params) or die "Cannot spawn \n"; my $exp = Expect->spawn("/usr/bin/python /opt/vtools/Scripts/reportcon +solidator.py /opt/vtools/Healthcheck/$dDate > /opt/vtools/HealthRepor +t.out") or die "Cannot spawn \n"; unless ($exp->expect(3,'-re',$match)) {}; print $exp "$response1\r"; #unless ($exp->expect(3,"Do you want to unpack these archive files + for processing? [Y/N]:")) {}; #print $exp "$response1\r"; #unless ($exp->expect(700,"Do you want to process these CDR files? + [Y/N]: ")) {}; #print $exp "$response2\r"; #unless ($exp->expect(5,"Do you want to process these health summa +ry files? [Y/N]: ")) {}; #print $exp "$response1\r"; $exp->soft_close();
OUTPUT Snippet
vtools@txslws1d03:/opt/vtools/Scripts$ ./Fullhealthprep.pl Spawned '/usr/bin/python /opt/vtools/Scripts/reportconsolidator.py /op +t/vtools/Healthcheck/01_02_2014 > /opt/vtools/HealthReport.out' spawn id(3) Pid: 11561 Tty: /dev/pts/0 at /usr/local/share/perl/5.14.2/Expect.pm line 181 Expect::spawn('Expect', '/usr/bin/python /opt/vtools/Scripts/r +eportconsolidator.py /op...') called at ./Fullhealthprep.pl line 27 expect(Expect=GLOB(0x9f695bc) 3 -re Do you want to unpack these archiv +e files for processing? [Y/N]: ) called... expect(): handling param '-re'... expect(): handling option '-re'... Starting EXPECT pattern matching... at /usr/local/share/perl/5.14.2/Expect.pm line 561 Expect::expect('Expect=GLOB(0x9f695bc)', 3, '-re', 'Do you wan +t to unpack these archive files for processing? [Y/...') called at ./ +Fullhealthprep.pl line 29 spawn id(3): beginning expect. Timeout: 3 seconds. Current time: Thu Jan 2 17:10:51 2014 spawn id(3): list of patterns: #1: -re `Do you want to unpack these archive files for processing? [ +Y/N]: ' spawn id(3): Does `' match: pattern #1: -re `Do you want to unpack these archive files for proce +ssing? [Y/N]: '? No. Waiting for new data (3 seconds)... TIMEOUT Returning from expect with TIMEOUT or EOF Closing spawn id(3). at /usr/local/share/perl/5.14.2/Expect.pm line 1354 Expect::soft_close('Expect=GLOB(0x9f695bc)') called at ./Fullh +ealthprep.pl line 37 Y Got EOF from spawn id(3). spawn id(3) closed. Pid 11561 of spawn id(3) exited, Status: 0x00 Closing spawn id(3). at /usr/local/share/perl/5.14.2/Expect.pm line 1431 Expect::hard_close('Expect=GLOB(0x9f695bc)') called at /usr/lo +cal/share/perl/5.14.2/Expect.pm line 1621 Expect::DESTROY('Expect=GLOB(0x9f695bc)') called at ./Fullheal +thprep.pl line 0 eval {...} called at ./Fullhealthprep.pl line 0

In reply to Perl Expect not matching by rayvn11

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.