[英]Automation of [y/n] in Debian/Linux
I am writing a script file to automate. 我正在编写一个脚本文件来自动化。 I am downgrading a Php version of the machine.
我正在降级机器的Php版本。 The command that I am using is interactive.
我正在使用的命令是交互式的。
It will ask me three question which I need to respond to in the form of n/Y/q. 它会问我三个问题,我需要以n / Y / q的形式回答。
I know I can use yes | {command}
我知道我可以使用
yes | {command}
yes | {command}
. yes | {command}
。 But I need to give series of No,Yes,Yes. 但是我需要给出一系列否,是,是。
How can I do that? 我怎样才能做到这一点?
I even tried doing echo " NYY" | command
我什至尝试做
echo " NYY" | command
echo " NYY" | command
but it's not working. echo " NYY" | command
但不起作用。
I am using Debian Wheezy. 我正在使用Debian Wheezy。
Any help? 有什么帮助吗?
您需要在每个答案之间添加换行符:
printf "N\nY\nY\n" | command
You need new line character '\\n': 您需要换行符'\\ n':
echo -ne 'N\nY\nY\n' | command
Failing that you can use expected which was already mentioned. 未能使用您已经提到的期望值。
尝试这个
echo N Y Y | xargs -n 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.