I have a script that will install software on all remote host. At the end of the script it starts the install.sh part and goes into a interactive mode asking Yes or No questions and prompting to add a username and password. My question is how can I script this so that these questions are answered automatically? Here is my script.
#!/bin/ksh
PATH=/usr/bin:/usr/sbin:/opt/local/bin:/usr/local/bin
PGM=`basename $0`
HOSTS=$1
[[ -z $HOSTS ]] && HOSTS="`grep -v \# /opt/local/etc/hosts|grep -i atl380g5test|nawk '{print $1}'`"
echo "$PGM: Installing Sophos AntiVirus Software"
for host in $HOSTS
do
printf "o PROCESSING HOST: %-20s\n" $host
ping $host 1>/dev/null 2>&1;
if (( $? )) ; then
echo "--Cannot contact host $host";
else
scp /admin/install.sophos.tar $host:/opt/install.sophos.tar
echo " --installing Sophos Antivirus software on $host"
ssh $host 'cd /opt/ ; tar -xvf install.sophos.tar;
/opt/sofos/install.sh; rm -r install.sophos.tar
echo " The script will ask you a series of Y or N questions. press enter to start"
fi;
done
The scripts starts the install part then ask a series of questions I want to automate and need assistance with. thanks..
o you accept the licence? Yes(Y)/No(N) [N]
>
Y
Where do you want to install Sophos Anti-Virus? [/opt/sophos-av]
>
enter
Sophos Anti-Virus GUI is accessible at
The UNIX and Linux Forums - Learn UNIX and Linux from Experts from your web browser.
You must now enter a username/password for Sophos Anti-Virus GUI. If you enter a blank password, the Sophos Anti-Virus GUI will be
disabled.
Username for Sophos Anti-Virus GUI? [
admin]
>
Password for Sophos Anti-Virus GUI?
>
test1
Re-enter the same password.
>
test1
Do you want to enable remote management? Yes(Y)/No(N) [
Y]
>
Do you want to enable on-access scanning? Yes(Y)/No(N) [
Y]
ar'