How to get Fabric to automatically (instead of user-interactively) interact with shell commands? Combine with pexpect?

前端 未结 3 520
不知归路
不知归路 2020-12-05 05:18

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

3条回答
  •  孤街浪徒
    2020-12-05 06:02

    It's not either/or. You just need to run the fab command through pexpect:

    child = pexpect.spawn('fab ')
    child.expect('prompt:')
    child.send('reponse to prompt')
    ... etc
    

    The fab command is just like any other command, so it can be scripted through pexpect.

提交回复
热议问题