On Friday 19 November 2004 7:18 pm, Chris Devers wrote:
> On Fri, 19 Nov 2004 [EMAIL PROTECTED] wrote:
> > I wanted to get the IP address and the OS of the system when some
> > one checks in the page...How will I get the IP address and OS of
> > the person who visits the page(with PERL CGI)
>
> As I was saying the last time you asked a version of this question --
> I think it was yesterday, or maybe the day before -- look in the %ENV
> hash. There are plenty of examples for this online if you can't
> figure out how to examine it on your own.

Bellow is a usefull CGI that I use for debugging occasionally, and 
included you will see the variables that you think may work for you, 
including remote IP, remote hostname etc.

However, they are not to be trusted a) because they can be spoofed as 
already been said. b) if there is a web cache/proxy inbetween, such as 
a transparrent proxy run by the viewer's ISP then that's what you'll 
get.

#!/usr/bin/perl
#
# CGI script to print out the relevant environment variables.
# It's just one big print statement, but note the use of the
# associative %ENV array to access the environment variables.
#

print <<EOF;
Content-Type: text/html

<HTML>
<HEAD>
<title> CGI Tutorial: Environment variables script</title>
</HEAD>
<body bgcolor=FFFFFF text=000000 link=0000ff alink=ff0000 vlink=800080>
<center>

<hr width=80%>
<h1> Environment variables script</h1>
<hr width=80%>

<p>

Here are the environment variables that this CGI script has been
called with.

<p>
<hr width=80%>

<table width=80%, border=2>
  <tr>
    <th width=30%>Label</th>
    <th width=50%>Value</th>
  </tr>
EOF

while (($KEY,$VALUE) = each(%ENV)) {
  $VALUE='&lt;empty&gt;' if (!$VALUE);
  print "
  <tr>
    <td width=30%>$KEY</td>
    <td width=50%>$VALUE</td>
  </tr>
";
}
print "</table> </center> <pre>";

chomp(@SETS = qx!/bin/bash -c set!);

for(@SETS) {
  print "$_\n";
}
print "
</PRE>
</BODY>
</HTML>";                       # Print statement (and program) ends 
here

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to