From: r.albanese at qut.edu.au (Rico Albanese)
Date: Tue, 18 May 1999 17:11:30 +1000
Subject: Accessing REMOTE_ADDR from web page
Message-ID: <374112A2.9CC3B6F@qut.edu.au>
Content-Length: 1126
X-UID: 1871                                                 

Hi everyone,

Can someone tell me how to access the REMOTE_ADDR shell environment
variable which is sent with a web page request to a web server.  I have
a job logging application which uses a web page which calls a Python
script to enter a request into a database.  I wish to collect also the
ip address of the workstation that is making the requesting so that we
may better manage a our ip addresses in our faculty.

I have used the following code :

import cgi
.
.
.
theenviron=cgi.print_environ()
.
.
print theenviron

This produces the following output:

<DT> PATH <DD> C:\Python;C:\Perl\bin;C:\WINNT\system32;C:\WINNT;
<DT> PYTHONPATH <DD> c:\python
<DT> QUERY_STRING <DD>
Name=&amp;PhNumb=&amp;Locn=&amp;Schl=NS&amp;urgency=D&amp;JobDesc=&amp;
<DT> REMOTE_ADDR <DD> 131.181.38.141
<DT> REMOTE_PORT <DD> 1288
<DT> REQUEST_METHOD <DD> POST
<DT> REQUEST_URI <DD> /cgi-bin/ra2jblog.py

My question is how do I access the REMOTE_ADDR??  Is "theenviron" a
string,list, tuple what??

I have tried doing a string search, but to no avail.  I still get the
same printout above.

Any help would be appreciated.

Thanks

Rico






