in reply to Solved: Need Help in running Expect script in Perl
First, it has been a while since I've used CPAN Expect, so my advice may not be accurate.
Second, I want to clarify your problem. You are saying that when output gets here:
SWBKPT hit for SLOT 1..!! PC-Value : 0x124 Blk Count = 1 Cycles +: 332
...your Perl script does not seem to send the "\n" so that the console program will continue.
I see two potential problems. One, you have really short timeouts (2 seconds). Two, you are expecting "SWBKPT hit for SLOT" but some text is still being output after that match. Thus, it is possible the "\n" is being sent before the console program is reading input and the "\n" send is not buffered.
To help debug, try calling the expect() method in array context, then dump the array to see the status of the expect() call.
use Data::Dumper; my @exp_stat; @exp_stat = expect "SWBKPT hit for SLOT"; print Dumper(\@exp_stat);
And read this explanation from the CPAN Expect docs:
If called in an array context expect() will return ($matched_pattern_position, $error, $successfully_matching_string, $before_match, and $after_match).
$matched_pattern_position will contain the value that would have been returned if expect() had been called in a scalar context. $error is the error that occurred that caused expect() to return. $error will contain a number followed by a string equivalent expressing the nature of the error. Possible values are undef, indicating no error, '1:TIMEOUT' indicating that $timeout seconds had elapsed without a match, '2:EOF' indicating an eof was read from $object, '3: spawn id($fileno) died' indicating that the process exited before matching and '4:$!' indicating whatever error was set in $ERRNO during the last read on $object's handle. All handles indicated by set_group plus STDOUT will have all data to come out of $object printed to them during expect() if log_group and log_stdout are set.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need Help in running Expect script in Perl
by subhasishn@yahoo.com (Initiate) on Mar 13, 2012 at 10:00 UTC | |
by jffry (Hermit) on Mar 13, 2012 at 15:58 UTC | |
by subhasishn@yahoo.com (Initiate) on Mar 14, 2012 at 06:42 UTC | |
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 | |
|
Re^2: Need Help in running Expect script in Perl
by subhasishn@yahoo.com (Initiate) on Mar 13, 2012 at 05:06 UTC |