bash: does expect work with multiple password prompts?

一个人想着一个人 提交于 2019-12-05 20:22:58

You have to do a little programming. Fortunately the answer is pretty simple:

#!/bin/sh

PASS=MyPassword
export PASS

/usr/bin/expect -c '
    spawn python Tools/python/install.py
    expect {
        -nocase "password:" {
            send "$env(PASS)\r"
            exp_continue
        }
        "somthing_else_that_indicates_you're_ready_to_interact"
    }
    interact
'

Cleaned up the shell quoting a little too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!