我想运行一个命令,提示我输入 yes/no 或 y/n 或其他。如果我只是运行命令 local("my_command")
然后它会停止并要求我输入。当我输入需要的内容时,脚本继续工作。如何自动响应提示?
最佳答案
从 1.9
版本开始,Fabric 包含了一种正确管理它的方法。
section about Prompts在 Fabric 文档中说:
The prompts dictionary allows users to control interactive prompts. If a key in the dictionary is found in a command’s standard output stream, Fabric will automatically answer with the corresponding dictionary value.
你应该可以让 Fabric 自动回答这样的提示:
with settings(prompts={'Do you want to continue [Y/n]? ': 'Y'}):
run('apt-get update')
run('apt-get upgrade')
关于python - 如何使用 python fabric 自动回答提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479078/