Linux自动人机交互expect

exp_test.sh文件

#!/bin/bash/expect
## exp_test.sh
set timeout -1;
spawn ssh localhost;
expect {
    "(yes/no)" {send "yes\r";exp_continue;}
    "password:" {send "hadoop\r";exp_continue;}
    eof {exit 0;}
}

执行:expect exp_test.sh

posted @ 2018-03-01 09:53  理舞  阅读(301)  评论(0编辑  收藏  举报