I am trying to check whether particular host and port are responding or not. I am using below script to check. but node_port array that i am using in loop is getting replaced with previous iteration value. Script and output is given.
Please help me to understanding why node_port values are replaced and how to avoid that.
I am using bash shell for executing this.
host_names=(xx.yy.zz.167 xx.yy.zz.168 xx.yy.zz.169 xx.yy.zz.170 xx.yy.zz.171 xx.yy.zz.172)
node_port=(2100 2200 2300 2400 2500)
while :
do
LoopstartTime=$(date '+%Y-%m-%d %r %Z')
unset i j
for i in "${host_names[@]}"
do
echo "First Loop-$i"
for j in "${node_port[@]}"
do
echo " Second Loop-$j"
echo " variables list ${node_port[@]}"
echo " no of arg ${#node_port[@]}"
unset j
done
done
LoopendTime=$(date '+%Y-%m-%d %r %Z')
echo "Process started at ${LoopstartTime} and Completed at ${LoopendTime}"
echo " "
sleep $wait_time
done
Output is