我如何使用bash强制yum安装而不提示用户?


66

我正在写一个bash脚本来安装php5.4,我想针对测试VM自动化它。我拥有的rpm命令是:

rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
yum install php54w

现在,在此运行的中间,将提示用户输入[Y / N]是否下载依赖项。所以我要么需要:

  1. 模拟用户输入的[Y];要么

  2. 传递命令yum不要问并假设[Y]

bash脚本的最佳方法是什么?如何完成以上两项?

Answers:


98

您可以使用-y开关:

$ yum -y install php54w
摘自yum手册页
-y, --assumeyes
      Assume yes; assume that the answer to any question which would be asked
      is yes. Configuration Option: assumeyes

谢谢。那很快。有趣的是,我尝试在rpm上执行标志,但找不到它-但有意义的是yum就在这里。
布拉德利
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.