add timeout and eof cases to your expect invocations to decrease opaqueness, please,
i.e.
expect \
-re $patt.. {
set myvar $expect_out(...
} eof {
puts stderr EOF!
} timeout {
puts stderr TIMEOUT!
}
same with expecting the prompt.
THen look into your prompt.
Most apps produce prompts with trailing whitepspace.
Not expecting that whitespace leads to strange
seemingly timing dependent errors
uwe