Geographical location details of a server

Is there a way to find geographical location details of a server in shell scripting ? Say, which region server is located at etc.

you can use the any web service that serve the location information from your public IP-address for this issue and maybe like the below commas..

Most people use MaxMinds geoip libs for opensource geolocation information.


APIs for GeoIP Products

i tried this example and works

Find by IP - Perl IP to location Example

allright , these commands are poorly but the request is for shell script..
we can use the lynx or wget or other tools for pure shell env..

however did you mean "geoiplookup" ?
if it is that , as far as I know , geoiplookup return only Country ?

# geoiplookup 212.156.XX.XX
GeoIP Country Edition: TR, Turkey

maybe we can use this int the shell enviroment

# wget -qO - http://www.geoiptool.com/en/?IP="212.156.XX.XX"|sed -n '/City</s#.*City</strong>: \([A-Za-z][A-Za-z]*\).*Country</strong>: \([A-Za-z][A-Za-z]*\).*#\1 --> \2#p'
Istanbul --> Turkey

regards
ygemici

The way I see it is that if you are operating in a shell within a unix/linux environment, you are "in the shell" and if running script (any script) withing the shell you are running a "shell script".

This also means that you could compile the C code from MaxMinds that goes geolocation and run that binary "in the shell" and you are running a "shell script".

We run MaxMinds geolocation code/scripts on many web sites, and sometimes the requirement is for continent, country, region, state, designated metropolitan area (DMA), city, or even area code or zip code.

Frankly, I would never do this calling a service using wget or curl; because that would be adding an unnecessary, unreliable, and slow network call across the net to get geolocation data that is easily obtained with the various (free, opensource) MaxMinds APIs. mod_geoip for Apache is based on the same code.