Python的面料:如何回答键盘输入? [英] Python Fabric: How to answer to keyboard input?

查看:101
本文介绍了Python的面料:如何回答键盘输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动执行一些程序促使一些问题的答复,如MySQL提示输入密码,或apt要求一个是或...当我要重建我的草堆指数与./manage的.py rebuild_index。

I would like to automate the response for some question prompted by some programs, like mysql prompting for a password, or apt asking for a 'yes' or ... when I want to rebuild my haystack index with a ./manage.py rebuild_index.

对于MySQL,我可以使用--password =开关,我敢肯定,容易有一个安静一样的选择。但我怎么能传递到其他程序的反应?

For MySQL, I can use the --password= switch, and I'm sure that apt has a 'quiet' like option. But how can I pass the response to other programs ?

推荐答案

为什么你就不能使用管道

例如,用于自动自动接受,只是使用 ,只是输出 y的永无止境的流

For example, for an automated auto accept, just use yes, that just outputs a neverending stream of y.

yes | rm *.txt

这篇关于Python的面料:如何回答键盘输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆