expect实现命令行自动交互 2017-10-10 • Lu Tao 文件名:loginServerByExpect.exp #!/usr/bin/expect -f #记录日志 log_file -noappend "/data/log/expect.log" set timeout 30 # 密码通过参数传递 set password [lindex $argv 0] spawn ssh root@master-evm1 expect "password:" send "$password\r" #进入交互模式 interact 使用方法: chmod a+x loginServerByExpect.exp ./loginServerByExpect.exp thisispassword 参考链接 expect用法