Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't understand why expect gets "ahead" of itself - send command too

Status
Not open for further replies.

LilTCLer

Programmer
Nov 27, 2007
37
US
OK, I'm stumped. I have a script that reads a file (of CLI commands)line-by-line and takes each line and appends it to an array/list. Now the list is a bunch of CLI commands. I then loop through each element in the list and send the CLI command to a spawned telnet session to my DUT.

Once I send the command, if I receive a "%", then expect should stop, as this indicates an error and wait for the user to interact. For some reason, the script send in one command, it errors, yet expect sends half of the next command such as seen below:

T7100-DUT-5(config)#
T7100-DUT-5(config)# aps lock2
% Invalid Command
T7100-DUT-5(config)# aps l <-- Don't know why this is sent before the "waitForUserVerification" from the first failure is addressed



###################################################################
ERROR Encountered: Please resolve, verify and continue...
###################################################################


Continue [y or n]:

After the first "expect" of the "%", it should stop. I can't understand why. Here is a snippit of my code:

for { set command 0 } { $command <= $commandListLength } { incr command } {

set send_cmd [ lindex $commandList $command ]
append send_cmd "\r"
exp_send -s -i $id $send_cmd
expect {
-i $id -gl "\%" {
printBanner "ERROR Encountered: Please resolve, verify and continue... "
waitForUserVerification
checkSystemConnectivity $shelfUnderTest
}
-i $id -gl "*T7100-$systemSID-$shelfUnderTest*" { continue }
timeout {
printBanner "ERROR: Command attempt timed out for CMD: \"$string\" "
waitForUserVerification
checkSystemConnectivity $shelfUnderTest
}
}

Can anyone offer me any clues?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top