I am writing a bash script that is supposed to do some confirmation and also install software. First step of the installation process is that I am being asked to confirm the EULA and type 'yes'. Is there a way to get the 'yes' in there from the bash script?
A:
Use read
.
#!/bin/sh
echo -n "Confirm? (y/n):"
read confirm_val
if [[ "$confirm_val" == "y" ]] ; then
echo "Confirmed!"
else
echo "Not confirmed!"
fi
Trent Davies
2010-03-05 03:31:39
Well this script prompts the user to confirm, What I need is the opposite. The software I am trying to install from my script asks me to confirm their EULA. Now my problem is how to confirm their EULA from my script.
ajmurmann
2010-03-05 03:42:07
A:
#!/bin/sh
echo -n "Confirm me ? (yes/no):"
read choice
if [ "$choice" == "yes" ] ; then
echo "Confirmed!"
else
echo "Not confirmed!"
fi
muruga
2010-03-05 03:44:02
+2
A:
The command yes
outputs a never-ending stream of a specified string, or y
if unspecified.
$ yes | head y y y y y y y y y y $ yes yes | ./interactive-installer # something like this?
ephemient
2010-03-05 03:48:33
+1
A:
Expect may be of help there. I've never used it myself, but I understand that it allows you to specify pre-programmed responses to specific prompts.
Chris Jester-Young
2010-03-05 03:49:36