1 安装服务
yum install -y expect
2 案例(这里写成了函数,直接导入函数即可,还可以重定项输出!)
jx(){ expect <<EOF set time 30 spawn vncpasswd expect { "Password:" { send "111111\r"; exp_continue } "Verify:" { send "111111\r"; exp_continue } "Would you like to enter a view-only password (y/n)?" { send "n\r" } } expect eof EOF }
标签:脚本,shell,函数,expert,expect,交互 From: https://www.cnblogs.com/glwst/p/17198361.html