Hi guys.
Im having a little trouble with one of my phyon cgi scripts.
Basically i need to a function that runs on the server size as a python cgi script but returns the IP address of the web based user on the website. I then use the IP as an ideantifier for some other processes and data logging.
The script i have is:
def getIP():
"""Get host IP address"""
IP = socket.gethostbyname(socket.gethostname())
x = 0
outstr = ''
while (x < len(IP)):
if (IP[x] != '.'):
outstr = outstr + IP[x]
x += 1
return (str(outstr))
The while loop is just to get rid of the '.' in the string as i dont need them.
The problem is that while socket.gethostbyname(socket.gethostname()) returns the correct result when run locally on my machines it simply returns the IP address of my web host server when i run it on the host side.
Any ideas how to return the IP address of the user to the host so i can use it.
Ive seen services such as http://www.showmyip.com/ but i am wary of using these as the project is for my thesis.
I have also seen code that uses cgi.os.environ['REMOTE_ADDR']
but this gives me errors when i try to return it.
Cheers.
Ed