How do I force yum to install without prompting the user, using bash?

I’m writing a bash script to install php5.4 and I’d like to automate this for a test VM. The rpm command I have is:

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

Now, in the middle of this running, there is a user prompt to enter [Y/N] whether or not to download the dependencies. So I either need to:

  1. Simulate the user input of [Y]; or

  2. pass in a command for yum not to ask and assume [Y]

What is the best method for a bash script and how do I accomplish both of the above?

Asked By: Bradley

||

You can use the -y switch:

$ yum -y install php54w

excerpt from the yum man page

-y, --assumeyes
      Assume yes; assume that the answer to any question which would be asked
      is yes. Configuration Option: assumeyes
Answered By: slm
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.