I have a for loop as follows:
mapfile -t ipLast < SippIPs.txt
echo " ---- SIPp ---- "
echo "Please give count of SIPps needed to generate calls.."
read -p 'Sipps count starts from: ' start; read -p 'Sipps count ends on: ' end
if [[ -z $start ]] || [[ -z $end ]]; then echo "User pressed ENTER with no input text"; fi
for ((j=$start; j<=$end; j++)); do
sipps=${j[@]}
ipList=(${ipLast[sipps-1]})
if [[ "$end" -eq 0 ]]; then
echo "No way it cannot end on 0"
exit
fi
echo " ---- Launching SIPp $sipps ---- "
sshpass -p "root12" ssh -tt -o StrictHostKeyChecking=no root@$ipList <<EOF1
pkill -f sipp
screen -S sipp -d -m bash -c 'cd /usr/local/src/sipp-3.3; ulimit -Hn 65535; ulimit -Sn 65535; ./sipp -i $ipList -mi $ipList -sf HA_demo.xml -inf HA_demo.csv 10.171.0.231:5060 -p 5060 -r 1 -rp 1s -l 1 -m 1 -watchdog_minor_threshold 1500 -watchdog_major_threshold 4000 -watchdog_major_maxtriggers 30 -trace_err -aa -d 350s -oocsn ooc_default -t u1 -trace_screen -skip_rlimit && exec bash'
exit
EOF1
done
I want to convert the for loop to while loop such that after giving the count it returns to the loop to ask the user if they want to quit or keep launching SIPp.
My try:
mapfile -t ipLast < SippIPs.txt
read -p 'Sipps count starts from: ' start; read -p 'Sipps count ends on: ' end
j=$start
while (j<=$end); do
sipps=${j[@]}
ipList=(${ipLast[sipps-1]})
if [[ "$end" -eq 0 ]]; then
echo "No way it cannot end on 0"
exit
fi
echo " ---- Launching SIPp $sipps ---- "
sshpass -p "root12" ssh -tt -o StrictHostKeyChecking=no root@$ipList <<EOF1
pkill -f sipp
screen -S sipp -d -m bash -c 'cd /usr/local/src/sipp-3.3; ulimit -Hn 65535; ulimit -Sn 65535; ./sipp -i $ipList -mi $ipList -sf HA_demo.xml -inf HA_demo.csv 10.171.0.231:5060 -p 5060 -r 1 -rp 1s -l 1 -m 1 -watchdog_minor_threshold 1500 -watchdog_major_threshold 4000 -watchdog_major_maxtriggers 30 -trace_err -aa -d 350s -oocsn ooc_default -t u1 -trace_screen -skip_rlimit && exec bash'
exit
j++
EOF1
done