expect_after executes for spawn id 1 even if the corresponding expect executes for spawn id 2 
Author Message
 expect_after executes for spawn id 1 even if the corresponding expect executes for spawn id 2

I am using Expect 5.39 on Tcl 8.3 on Solaris platform.

I have two open spawn id (say exp1 and exp2). I also have an
expect_after block.

IMHO while expecting from the spawn id (exp2), only the statements (and
the expect_after block) corresponding to exp2, should be compared with
the output on exp2.

To my surprise, I find that Expect *also* tries to compare activity on
other spawn id (exp1) with exp_after block.

Apart from being surprising, IMHO it is inefficient and distracting
(while debugging a problem on exp2).

Can anyone explain to me this behavior of expect_after?

For your convenience, I attach the output of "exp_internal 1" here. In
the following example,

1. I am trying to expect on exp9.

2. It compares with correct output on exp9 with patterns corresponding
to exp9 related code. (No problems so far.)

3. However, please notice that it goes on comparing with reception on
exp8,7,6 and 5 with exp_after blocks (This is the problem)

4. ... before comparing reception on exp9 with the patterns again. (No
problem here again.)

What is wrong?

TIA,
-Kishore

*******

send: sending "\n no system disable telnet-server\n system set idle
-timeout telnet 0\n\rsave active" to { exp9 }
send: sending "\r" to { exp9 }

expect: does "" (spawn_id exp8) match regular expression
"Connection.*refused"?
no
"Unknown host"? no

expect: does "\r\nJul 08 12:55:52: %[8051acd#16#23]AAA-W-NOPASSWORD:
Authenticat
ion succeeded without password on vty 0.\r\nJul 08 12:55:52:
%[80514ce#16#23]AAA
-I-ACCESSGRANTED: Access granted  on vty 0 from 134.141.179.125."
(spawn_id exp7
) match regular expression "Connection.*refused"? no
"Unknown host"? no

expect: does "" (spawn_id exp6) match regular expression
"Connection.*refused"?
no
"Unknown host"? no

expect: does "\r\nJul 08 12:56:40: %[8051acd#16#23]AAA-W-NOPASSWORD:
Authenticat
ion succeeded without password on vty 0.\r\nJul 08 12:56:40:
%[80514ce#16#23]AAA
-I-ACCESSGRANTED: Access granted  on vty 0 from 134.141.179.125."
(spawn_id exp5
) match regular expression "Connection.*refused"? no
"Unknown host"? no

expect: does "" (spawn_id exp9) match regular expression
"[-A-Za-z0-9_.\-]+(\([-
A-Za-z0-9_.]+\))+# *$"? no
"More:"? no
full_buffer? no



Tue, 25 Dec 2007 21:42:31 GMT  
 expect_after executes for spawn id 1 even if the corresponding expect executes for spawn id 2

Quote:

> I am using Expect 5.39 on Tcl 8.3 on Solaris platform.

> I have two open spawn id (say exp1 and exp2). I also have an
> expect_after block.

> IMHO while expecting from the spawn id (exp2), only the statements (and
> the expect_after block) corresponding to exp2, should be compared with
> the output on exp2.

Is this your desired behavior, or do you see something in the documentation
that says this is so?

When I read the docs all I see is that when an expect block is being evaluated,
the most recent expect_before and expect_after blocks are also evaluated. I don't
see anywhere that it says there is any filtering based on spawn ids.

Given that, if you could also post relevent snippets of the script involved instead
of just the traces, someone here may be able to suggest a way to get your desired
behavior.

Bruce



Tue, 25 Dec 2007 22:17:15 GMT  
 expect_after executes for spawn id 1 even if the corresponding expect executes for spawn id 2
I want to capture the same behaviour that you are trying to explain.

The latest spawn id in the example is exp9

So, the expect_after block must be executed for exp9 only. Right?

IMHO I feel that expect_after must be executed on "one" spawn id,
whichever is the latest. The problem is that the block is being
executed for more than "one" spawn id.

The problem is that the exp_after block is executed for non-latest
spawn ids like  exp8, exp7 etc., as well.

- Kishore



Fri, 28 Dec 2007 19:29:27 GMT  
 expect_after executes for spawn id 1 even if the corresponding expect executes for spawn id 2

Quote:

> I want to capture the same behaviour that you are trying to explain.

> The latest spawn id in the example is exp9

> So, the expect_after block must be executed for exp9 only. Right?

> IMHO I feel that expect_after must be executed on "one" spawn id,
> whichever is the latest. The problem is that the block is being
> executed for more than "one" spawn id.

> The problem is that the exp_after block is executed for non-latest
> spawn ids like  exp8, exp7 etc., as well.

> - Kishore

To clarify the matter further,

exp_after block seems to apply

to each open spawn_id rather than
to the latest *referred to* channel (using -i)

- Kishore



Fri, 28 Dec 2007 21:04:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. A VI opens when executing, even if I don't want to

2. expect: spawn id exp7 not open error.

3. issues with expect -send: spawn id exp4 not open

4. Exploring Expect Q about spawn id and -i option

5. Invalid spawn id in Expect and HTTP

6. Expect problem: invalid spawn id

7. Expect:invalid spawn id

8. interact expect eof & invalid spawn id

9. Expect limits spawn-id count.

10. EXPECT, invalid spawn id

11. Help with Expect error - invalid spawn id

12. expect: Invalid spawn id/EOF problems

 

 
Powered by phpBB® Forum Software