I am trying to allow a user to input the number of ip addresses that they want to interface with, then enter each ip address and have it assigned to a variable. The script will ultimately write and execute a second script. The reason for the second script is that I am ssh-ing into an AP in order to cluster x number of AP's together, and once SSH occurs, bash/python variables are no longer passed through(the AP has it's own language), so they must be translated to plain text before the ssh script is run. The code below functions but allows only 2 ip addresses(I couldn't figure out how to use the $cvar to create multiple variables), and does not allow me to decide how many ip addresses to enter:
#!/bin/bash
echo -e "How many AP's do you want to Cluster?:"
#this is the variable to define how many ips to ask for
read cvar
echo -e "Enter last 2 digits of AP #1:"
read ip1
echo -e "Enter last 2 digits of AP #2:"
read ip2
#I want this to continue for x number of ip addresses(defined by $cvar)
echo -e "Enter a name for your Cluster:"
read cname
#code below is executed within the AP terminal(commands are unique to that shell)
echo "#!/bin/bash
ssh -T admin@192.168.0.$ip1 <<'eof'
configure
cluster
add $cname
add-member 192.168.0.$ip1 user ***** password ********
save
add-member 192.168.0.$ip2 user ***** password ********
save
exit
operate $cname
save
exit
" > ./2ndScript.sh
chmod a+x ./2ndScript.sh
/bin/bash ./2ndScript.sh