📜  在期望脚本中手动输入 sudo 密码 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:46.747000             🧑  作者: Mango

代码示例1
expect {
    "Input 1" { send -- "$env(input1)\r"; exp_continue }
    "Input 2" { send -- "$env(input2)\r"; exp_continue }
    # Only this bit is necessary
    "password for" { stty -echo
                    interact -u tty_spawn_id -o "\r" return
                    stty echo
                    exp_continue }
     # Up to here
    eof
}