expect的超時處理

##timeoutbash

#!/bin/bash
/usr/bin/expect <<-EOF

set timeout 10000

spawn scp xixicat@10.12.191.128:/home/xixicat/demofile .
expect -exact "xixicat@10.12.191.128's password:"
send "demopwd\r"
expect "100%"
expect eof
EOF
echo "finish"

若是沒有設置timeout,或者timeout不夠長,那麼就不能保證spawn的效果,因爲網絡緣由,有可能超時,先send密碼了,以後才返回要expect密碼。網絡