@bingoogolapple 2017-08-08 00:20:02发表于 bingoogolapple/bingoogolapple.github.io Linux
#!/usr/bin/expect -f # 设定超时时间为 3 秒 set timeout 3 # fork 一个子进程执行 ssh 命令 spawn ssh root@localhost # 期待匹配到输入密码提示 expect "*pass*" # 向命令行输入密码并回车 send "youpwd\r" expect "]*" send "cd /opt\r" send "ls\r" # 允许用户与命令行交互 interact