Thank you Olaf, I appreciate you taking the time to help me.
To answer your question, its part of a script to automate VM builds. I have VM build script written and it works. There are some parts that are going to vary each run, like IPs. The IPs that are used are not always in sequence, but sometimes go for a longtime in sequence. Choosing an IP randomly may have a better success rate than testing 10’s of IPs in sequence before finding one that is free. We will find a better solution in time, but this will do for now.
May I ask why you chose to create the script the way you have? Was my original script not able to work with some small changes? Can you advise where I was going wrong?