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