2.1k 次閱讀 · 讀完須要 2 分鐘shell
0segmentfault
#!/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