Python结构响应输出中的提示 [英] Python fabric respond to prompts in output
本文介绍了Python结构响应输出中的提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要用python的结构解决两个问题.
I have two problems I am trying to solve with fabric for python.
- 我想在提示符下自动输入密码:
- I'd like to auto-enter the password at the prompt:
- fabric password
以上链接所示,这两种方法都应该可行,但我无法使它们正常工作.当我通过fab test
Both of these should be possible as the above links show, but I can't get them to work. When I run the following file via fab test
from fabric.api import run, env, settings
env.hosts = ['<user>@<host>']
env.passwords = {'<user>@<host>': '<password>'}
def test():
with settings(prompts={"Please select a menu item: ": "1",}):
return
run("ls")
我的输出是:
[<user>@<host>] Login password for '<user>':
这时我必须输入密码,而不是自动输入 .然后,根据远程主机,我得到一个要自动响应的菜单,但是提示的自动完成功能不起作用.
At which point I have to type my password, instead of auto-entering. Then per the remote host I get a menu which I want to auto respond to, but my prompt's auto-complete doesn't work.
[<user>@<host>] out: <a menu>
[<user>@<host>] out: Please select a menu item:
我需要怎么做才能自动输入密码并自动回答此提示?
What do I need to do to get this to auto-enter my password and auto-answer this prompt?
推荐答案
查看全文