expect的超时处理

expect的超时处理

 2.1k 次阅读  ·  读完须要 2 分钟shell

0segmentfault

timeout

#!/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密码。bash

相关文章
相关标签/搜索