I am using bits and pieces of tkimpton's script https://jamfnation.jamfsoftware.com/discussion.html?id=5327 and I am wanting to do an ip address comparison. How can I take the existing computer ip address and compare it to our ip range. as an example I have a computer that is at ip address 123.456.789.123 and I want to make sure that it falls in the range 123.456.xxx.xxx? All I want to compare are the first two sets of numbers and disregard the rest. Thanks in advance for any insight to this!
Solved
WifI Script

Best answer by mm2270
Without really looking at the original script, you're going to want to create a new variable with just the first two sets of numbers. You can use cut in the script for that. Assume the current IP Address is stored in a variable called $IPADD, then:
IPSubnet=$( echo "$IPADD" | cut -d. -f1,2 )
This would give you "123.456" in your case above.
Later in the script simply do a if = then check like so
if [[ "$IPSubnet" == "123.456" ]]; then
**do something**
else
* do something else*
fi
And there are probably about 6 other ways if not more this can be done, so this is only one example. Someone may have an even better way to do it.
Hope that helps.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.