| Module Info
| Add a review of Expect
This is a great module for manipulating a console application programmatically. It is useful for testing, automation and many other uses. Highly recommended.
I had to test over 200 legacy shell script when we converted them to use a more secure method for database connections. Without this module I could have never done such a thorough job of testing and making sure that everything ran correctly.
I went through several iterations of my testing module and Expect was able to do whatever I needed. I created a driver file with all of the parameters needed to run each script and created a script to read the driver file and start, and then monitor each script for completion. The regular expressions available in pattern matching allowed me to cycle through repeatedly and watch for the completion messages of scripts. I was also able to monitor for signals indicating completion of scripts without completion messages. Expect was able to give all of the information I needed about each process, as well as logging all inputs and outputs of each script to both a master log and individual logs for each script.
I have used this module for about 7 years or so and I have little trouble with it. Both Austin and Roland have been very responsive to any issues that have been raised on the SF mailing list. They've taken care in how they're extended the interface, and the extensions have imporved the maintainability of the programs that I've written using Expect.
And the best part is that I can avoid Tcl completely.
This version builds on AIX 126.96.36.199, but it hangs up on the first test, which is a simple spawn of the perl -v command. I have communicated with the author about this problem and am hoping for a resolution.
This is how it hangs up:
PERL_DL_NONLAZY=1 /pcom/perl/perl-5.8.4/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
If you look at test.pl, you'll see that it's hanging up at this line:
my $exp = Expect->spawn("$Perl -v");
I debugged the module and found that it is hanging up at line 124 in
Expect.pm. This is the line of code:
my $errstatus = sysread(STAT_RDR, $errno, 256);
I have seen other complaints about either test failures or hang ups
on bulletin boards. It seems a lot of people are having this problem, and not just on AIX.