There is no variable named IP, thus $IP yields the empty string.
Your can achieve what you want (looks like a load balancer written in Bash
) with an array. For example:
Code:
IP=(69.46.87.106 69.46.87.107 69.46.87.108 69.46.87.109 69.46.87.110)
echo ${IP[$D]}
See also the
array section in the bash reference manual.
EDIT: Array indexes start at 0, not 1. You would have to tweak your code so that D ranges from 0 to 4. Or insert a dummy address at the beginning of the array (which would be an ugly hack).