expect

#!/usr/bin/expect
spawn ssh remotehost
expect "*some key word*"
send "kinit -f
"
expect "*assword*"
send "password
"
send "cmd1
"
send "cmd2
"
send "df -h
"
send "hostname
"
send "date
"
interact

 . /cfg

读取cfg文件中设置的环境变量,别名

原文地址:https://www.cnblogs.com/Searchor/p/12103759.html