expect

expect -c "
set timeout 1200;
spawn kinit hdfs
expect {
\"*Password*\" {send \"${FIhdfsPW}\r\";}
}
expect eof;"

一段比较好用的shell脚本

#!/bin/bash
#scp tar.gz to httpd
expect -c "
spawn ssh root@IP
expect {
    \"*yes/no*\"
    {
        send \"yes\r\"
    }
}
expect eof;"

expect -c "
spwan ssh root@IP
expect {
    \"*Are*\"
    {
        send \"yes\r\"
    }
}
expect eof;"

expect -c "
spawn scp demo [email protected]:/lujing/
expect {
    \"*Password*\"
    {
        send \"mima@123\r\"
    }
}
expect eof;"

你可能感兴趣的:(expect)