首页 > 系统相关 >shell脚本中expert交互

shell脚本中expert交互

时间:2023-03-09 14:58:37浏览次数:43  
标签:脚本 shell 函数 expert expect 交互

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

相关文章