Expect Script - Need help to find solution

I am facing below issue with my script. below is one of the test out of 50 test from the tool which i m trying to automate. the test may show up or may not depending upon the previous results and also from the test some inputs may be asked or may not be asked depending upon previous results so you can assume 40% of input are volatile?

#Checking Hist_DB_Connectivity
expect  "Enter Historical database user name (*): "
send "dbuser\r"
expect  "Enter password (*):*"
send "dbuser\r"
expect  "Choice 1 or 2 (*):"
send "1\r"
expect  "Enter the host name or IP address (*):"
send "dbhost1\r"
expect  "Enter the port number:  (1521):"
send "1521\r"
expect  "Enter database service name (*):"
send "instance1\r"
expect  { 
"Enter e to execute again or press Enter to continue"
        { send "\r" ; exp_continue}
}

the tool checks for 56 test and some test may show up and may not depending upon previous result is pass or fail so i am using expect as

expect  { 
"Enter e to execute again or press Enter to continue"
        { send "\r" ; exp_continue}
}

is this a right way to enter the input only if this shown while executing tool on some of the test this script is failing and i tried to debug but it has so much information that i m not able to understand why its getting time out and expect sending the inputs even if that is not matching with why i quoted to matched?

Hi,

I feel its the right way as long as it works. You have to manually figure out all the possibilities before you can actually put expect to work on that otherwise you are sure to get unexpected results.

I have worked with expect a lot and at times it can get real slow and troublesome. But thats the way it works.

Regards,
Gaurav.