spawn 启动新的进程

expect 从进程接收字符串

send 向进程发送字符串

interact 允许用户交互


远程登录linux系统

#!/usr/bin/expect

set timeout 30

spawn ssh -l root 192.168.130.195

expect "(yes/no)?"

send "yes\r"

expect "password:"

send "123456\r"

interact