Accessing REMOTE_ADDR from web page
Rico Albanese
r.albanese at qut.edu.au
Tue May 18 18:17:57 EDT 1999
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=&PhNumb=&Locn=&Schl=NS&urgency=D&JobDesc=&
<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
More information about the Python-list
mailing list