Hi!
since this is my first script using arrays and user input, I am facing too many problems.
In the script below, even if I enter "done" as a hostname , it still continues to go further and ask username and password.
Code :
#!/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
store_hostname[$c]=$host_name
c=$(( c + 1 ))
echo "Please enter the username"
read username
echo $username
store_username[$d]=$username
d=$(( d + 1 ))
echo "Please enter the password"
read password
echo $password
store_password[$e]=$password
e=$(( e + 1 ))
done
for i in c
do
#Create a destination directory
ssh -q ${store_username[$d]}@${store_host_name[$c]} mkdir temp
#scp files to host
scp -r /root/temp ${store_username[$c]}@${store_host_name[$c]}:/root/
done