Is there a way to access a Mac's geolocation from terminal?

vilmoskörte's answer appears to be a good one, but I took it upon myself to make a tool that does this for my own education. I put it on GitHub.

WhereAmI

A simple command line tool. No options, just runs and outputs Lat/Long, accuracy in meters, and a timestamp. It will need OS X Location Services to be turned on (System Preferences > Security & Privacy), and permission to gather your location (OS X will prompt you on first run).

Direct Download Link (.zip)


This already has been programmed, have a look at

http://iharder.sourceforge.net/current/macosx/locateme/


I'm the author of LocateMe, and I just discovered that I have to copy LocateMe into the /Applications folder for it to work in Mountain Lion. I'm not sure what I'd have to do to avoid that -- probably something about getting a cert, which I'm not likely to pursue anytime soon.

In the meantime, for LocateMe and probably the others, try copying them to /Applications and see if you have better luck.

-Rob


Those apps need to be signed with a developer certificate before they can authorise with the Core Location service. If you look in Console.app you can see the failed attempts to authorise:

31/12/2012 13:08:26.441 locationd[484]: Couldn't get information from PID 40084
31/12/2012 13:08:27.515 CoreLocationAgent[40086]: CodeSigningInforequest for pid=40084 

I’ve used my developer account to build and sign a new whereami binary. After you run it Mountain Lion will ask your permission to enable it to access location data.


I'm the author of CoreLocationCLI, mentioned in the comments above. Just wanted to note that we have moved the project to this location:

https://github.com/fulldecent/corelocationcli

Also, it now supports --once if you are only looking for a single output, rather than continuous output.

Lastly, there is a full binary on the project page as well if you would rather not compile it yourself. You will still need to authorize ("Would you like this app to be able to access your location") on the first app run.