I need to automate some installation, but in some commands it asks like
"are you sure u want to continue[y\n]=?"
How do I always pass y
to all such type of questions to automate my script?
echo 'y y y' | sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum install yum-plugin-replace
sudo yum replace mysql-libs --replace-with mysql55w-libs
sudo yum install mysql.`uname -i` yum-plugin-replace
echo yes "yes" | sudo yum install mysql55w mysql55w-server
sudo service mysqld start
sudo mysql_upgrade -u root
here is my shell script i need to execute it completely with out any such questions prompted.
This is best coupled with a case statement that can check to see if the user entered yes or no or something else. #!/bin/bash read -p "Do you want to proceed? (yes/no) " yn case $yn in yes ) echo ok, we will proceed;; no ) echo exiting...; exit;; * ) echo invalid response; exit 1;; esac echo doing stuff...
On Linux, there are three ways to run multiple commands in a terminal: The Semicolon (;) operator. The Logical OR (||) operator. The Logical AND (&&) operator.
A Sample Command That Asks a Yes/No Question. If we are doing this manually, we can just type y <Enter> and pass this prompt.
You can use the yes
utility:
$ yes | sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
Before resorting to the yes
command (which risks giving y as an answer to things other than yes/no questions), read the documentation for the command you're using to see if it has an option to assume a "yes" answer to all (or most) interactive prompts.
I haven't used rpm
much lately, but the --force
option might be what you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With