如何让 Fabric 自动(而不是用户交互)与 shell 命令交互?与 pexpect 结合?
Seeking 意味着让 Fabric 自动(而不是用户交互)与 shell 命令交互(而不仅仅是请求密码,但当没有诸如 apt-get install -y 之类的“stdin/交互式覆盖”可用时,也会请求用户输入)。
这个问题以及这些Fabric 文档表明 Fabric 只能将交互性“推送”回运行 Fabric 程序的人类用户。寻求在无人参与的情况下实现完全自动化。目前还没有“真正的”问题需要解决,只是为未来可能出现的障碍做好准备。
如果 Fabric 不能独占,则与 pexpect (或类似的替代机制)结合使用可能有用自动处理所有标准输入/提示?希望它不需要成为“非此即彼”之类的事情。如果适用的话,为什么不在同一程序/自动化中适当地利用两者(pexpect 和 Fabric)?
Seeking means to get Fabric to automatically (instead of user-interactively) interact with shell commands (and not just requests for passwords, but also requested user input when no "stdin/interactive override" like apt-get install -y
is available).
This question along with these Fabric docs suggest that Fabric can only "push the interactivity" back to the human user that's running the Fabric program. Seeking to instead fully automate without any human presence. Don't yet have a "real," current problem to solve, just preparing for possible, future obstacle.
Possibly useful to combine with pexpect (or similar, alternative mechanism) if Fabric can't exclusively handle all stdin/prompts automatically? Hoping it doesn't need to be an "either/or" kind of thing. Why not leverage both (pexpect and Fabric) where appropriate, if applicable, in same program/automation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为 Glenn,我会说使用 pexpect;另外,
看看我编写的用于编写 Fabric 的 pexpect 行为脚本的包装器:
另请参阅我的博客文章 fexpect 或如何使用 pexpect 处理 Fabric 中的提示
As Glenn, I would say use pexpect; in addition,
have a look at this wrapper I wrote to script the pexpect behaviour from fabric:
See also my blogpost on fexpect or how to handle prompts in fabric with pexpect
这不是非此即彼。您只需要通过 pexpect 运行 fab 命令:
fab 命令就像任何其他命令一样,因此可以通过 pexpect 编写脚本。
It's not either/or. You just need to run the fab command through pexpect:
The fab command is just like any other command, so it can be scripted through pexpect.
对于 Windows 用户,请使用 winpexpect。确保使用我链接的这个版本,因为这个版本修复了以前版本中的一些错误。
For Windows users, use winpexpect. Make sure to use this version I linked as this version fixes some bugs in previous versions.