shell脚本中输入yes的交互

ssh免密连接验证

expect -c "
set timeout 30
spawn ssh -p6900 root@${external_ip} hostname
match_max 100000

for {} {1} {} {
 expect {           
                    \"yes/no)?\" {
                                send \"yes\r\"
                                set timeout -1
                    } timeout {
                                exit
                    } eof {
                                exit
                    }
 }
}
"

 

你可能感兴趣的:(shell脚本中输入yes的交互)