in reply to Re^2: Need Help in running Expect script in Perl
in thread Solved: Need Help in running Expect script in Perl
I'm assuming you're using @pattern_list to hold the return values from expect() like this:
@pattern_list = expect "SWBKPT hit for SLOT";
If that is true, then $pattern_list[0] is the "matched pattern position", $pattern_list[1] is the "error" and $pattern_list[2] is the "successfully matching string". However, to debug this, we need all the values, which is why I asked you to use Data::Dumper.
If you want to print the array values without Data::Dumper, then do something like this:
Run example:my @arr = qw( bob sue jane); print "\@arr = " . join(':', @arr) . "\n";
my@mybox:~/sandbox $ ./4.pl @arr = bob:sue:jane
The reason all the values are important is because if $pattern_list[4] ("after match") has a value, then that probably means Expect is sending the "\n" before your console program is reading input.
Actually, you know what would be a quicker test of that? Insert a sleep() between your expect() and send() like this:
$expect->expect($timeout,"SWBKPT hit for SLOT"); sleep 2; $expect->send("\n\n");
Of course, this test assumes that it takes less than 2 seconds between when the console program prints "SWBKPT hit for SLOT" and when it prints "Cycles : 332".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Need Help in running Expect script in Perl
by subhasishn@yahoo.com (Initiate) on Mar 14, 2012 at 06:42 UTC | |
|
Re^4: Need Help in running Expect script in Perl
by subhasishn@yahoo.com (Initiate) on Mar 14, 2012 at 11:03 UTC | |
by jffry (Hermit) on Mar 14, 2012 at 16:10 UTC | |
by subhasishn@yahoo.com (Initiate) on Mar 15, 2012 at 07:28 UTC |