Python Fabric:如何处理输入的任意远程shell提示?

2024-06-01 11:04:04 发布

您现在位置:Python中文网/ 问答频道 /正文

这与这里的keyboard-input">question有关,但有一点小小的变化:我需要Fabric将任意字符串传递给远程shell,而不是仅仅传递“yes”或“no”。

例如,如果远程shell提示“what is your name?”然后我要喂它“先,后”。

澄清:我知道我说的是任意输入,但我真的是trying to use it for the SSH key passwd prompt when I try to do a git pull

更新1:Jeff Forcier@bitprophet回复


Tags: thetokeygitanforinput远程
3条回答

结构1.0最终支持与远程服务器的交互。有关详细信息,请参见this page

我已经在邮件列表中为这个功能在fabric中提出了一个API, 最后我自己写了些东西:

from fexpect import expect, expecting, run 

prompts = []
prompts += expect('What is your name?','John')
prompts += expect('Where do you live?','New York')

with expecting(prompts):
    run('command')

expecting prompts in fabric with fexpect上查看我的博客

也许去查一下pexpect

相关问题 更多 >