tags:

views:

56

answers:

0

The expect script was meant to test a network server. In the script, the server was first started, and then client A and B are started with telnet command. Client A was started before client B. The testing flow is:

  • client A starts, register to the server
  • client B starts, register to the server, send a message to client A
  • client A send a message to client B

The script failed in the last step. I always get a timeout due to some reasons. I tried to use send -i $client_a_spawn_id, but it seems not working. My code is as follows:

#!/usr/bin/expect
set spawn_id $client_a_spawn_id
send -i $client_a_spawn_id "\"This is now a test\"\n"
expect -i $client_a_spawn_id "success"
expect -i $client_b_spawn_id "This is now a test"

The failure is caused by the first expect. I always get a timeout but I couldn't find the reason. I tried to do the process manually, but was able to get the message on client B.