Find the current location of user via scripting

New Contributor II



We are looking to group users by the geo location when deploying nessus so our Security team have an idea what geolocation is user located in.


For a snippet i am trying where using date +%Z command, I grab the time zone and then assign the EDT to a variable if user is in EDT but when there is a change, I have to account for EST as well. This would mean bunch of variables containing bunch of timezones for all geolocations for grouping.


Another method was to use sudo fdesetup -gettimezone  and do a cross check of user is in America/ New York, assign to US group etc.


I want ask if anyone knows a builtin mechanism which just grabs the country of the geolocation that I can cross check against. I would like to avoid installing things like whereami etc on our machines


Thank you.


Honored Contributor II