Issue
I want to install java on many computers using ssh so I want to write a bash script that will do (roughly):
for c in computers
do
scp jre--.rpm $c
ssh $c 'sudu -s; chmod a+x jre--.rpm ; ./jre--.rpm; echo "success!"'
done
The problem is that during the java installation I need to "read" the notice and type "yes" at the end. How do I do it? Is there an easier way than "expect"? And if not how to I fit it in the bash script?
thanks a lot
Solution
expect is the way to go (thanks http://www.dnmouse.org/java.html):
for c in computers
do
scp jre--.rpm $c
ssh -t $c 'sudo -s; yum -y install expect; sudo chmod a+x jre--.rpm'
ssh -t $c '/usr/bin/expect -c \
"set timeout -1; spawn ./jre-6u13-linux-x64-rpm.bin; sleep 1; send -- q\r; sleep 1; send -- yes\r; expect eof"
echo "success!"'
done
Answered By - Guy