use Expect; # use strict; # commented out to allow program to run for now # Spawn program using perl expect module my $exp = Expect->spawn($run_program) or die "Cannot spawn $run_program: $!\n"; # Turn off output of results from stdout $exp->log_stdout(1); # Wait for runrep to initialise $exp->expect(600,[ qr/Read in all files/]); $exp->send("runprogram $report_name $output_format \n"); # Wait for report to run or generate an error $exp->expect(600, [ qr/Error/i, sub { my $self = shift; $self->send("quit\n"); print ("program.pl has an error: $_ \n"); exp_continue; }], # *** [ qr/Report run successful./i, sub { my $self = shift; $self->send("quit\n"); exp_continue; }]);} # ***