- 案例示范
[root@room4pc09 ~]# yum -y install expat
[root@room4pc09 ~]# vim test.sh
-#! /bin/bash
expect <<EOF #工具使用
set timeout 30 #时间设置等待时长最多30妙
spawn ssh 172.25.0.10
expect "password" { send "redhat\r"} #当出现password 输入 redhat 、r是回车
expect "#" {send "touch /new.txt\r"}
expect "#" {send "exit\r"} #最后一行是不执行的
EOF