Hi All,
Has anyone used expect script in a shell script or vice versa. I have a script which would ssh and scp to other machines. I need to use expect script so that user does not have to enter the password everytime ssh/scp command is executed.
The script is as below. I need to pass the store_password[$i] , store_hostname[$i] to the expect script.
#!/usr/bin/sh
##Take input from the user
c=d=e=0
while [ "$host_name" != done ]
do
echo "Please enter the host_name"
read host_name
if [ "$host_name" = done ] ; then break; fi
store_hostname[$c]=$host_name
c=$(( c + 1 ))
# echo "Please enter the username"
# read username
# store_username[$d]=$username
# d=$(( d + 1 ))
echo "Please enter the password"
read password
store_password[$e]=$password
e=$(( e + 1 ))
done
echo ${store_hostname[0]}
len=${#store_hostname
[*]}
echo $len
for (( i=0; $i < $len; i++ ))
do
#ssh -q root@${store_hostname[$i]} mkdir temp
scp -r /root/temp root@${store_hostname[$i]}:/root/
ssh -q root@${store_hostname[$i]} /root/temp/temp1.sh
done