1、首先安装iTerm2 工具
下载地址 http://www.iterm2.com/
2、编写脚本 保存到 ~/ssh/test.sh
#!/usr/bin/expect
set timeout 30
spawn ssh -p21 your name@127.0.0.1
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "your password\n"}
}
interact
3、打开iTerm2工具 运行 expect test.sh 即可