I am trying to write a script that shows the IP of incoming request. The code works, but gives me a wrong IP which it gets from I dont know were. I am running this code on tripod. Any idea why this shouldnt work?
#!/usr/local/bin/perl
my
@ip = ($ENV{REMOTE_ADDR});
print
Your IP is
@ipEND
Comments
[code]
sub access_log() {
open("ACCESS_LOG",">>../logs/.access_log");
$date = `date`;
print ACCESS_LOG "Date: $date
User: ";
print ACCESS_LOG $ENV{'REMOTE_USER'};
print ACCESS_LOG "
User IP: ";
$address=$ENV{'REMOTE_ADDR'};
print ACCESS_LOG "$address";
print ACCESS_LOG "
Script Location: ";
print ACCESS_LOG $ENV{'SCRIPT_NAME'};
print ACCESS_LOG "
--------------------------------------
";
close(ACCESS_LOG);
}
[/code]
Hope that helps
-----------------------
"The three principle virtues of a programmer are laziness, impatience, and hubris"
: Try setting it to $ip=$ENV{REMOTE_ADDR}. Its returning a string, and your trying to set an entire array equal to that string That works fine for me, I use it to log user access to my website. The following is the source:
:
: [code]
: sub access_log() {
: open("ACCESS_LOG",">>../logs/.access_log");
: $date = `date`;
: print ACCESS_LOG "Date: $date
User: ";
: print ACCESS_LOG $ENV{'REMOTE_USER'};
: print ACCESS_LOG "
User IP: ";
: $address=$ENV{'REMOTE_ADDR'};
: print ACCESS_LOG "$address";
: print ACCESS_LOG "
Script Location: ";
: print ACCESS_LOG $ENV{'SCRIPT_NAME'};
: print ACCESS_LOG "
--------------------------------------
";
: close(ACCESS_LOG);
: }
: [/code]
:
: Hope that helps
: -----------------------
: "The three principle virtues of a programmer are laziness, impatience, and hubris"
:
:
:
: #!/usr/local/bin/perl
:
: my @ip = ($ENV{REMOTE_ADDR});
:
: print <<END;
:
: Content-Type: text/html
:
:
: <html>
:
: Your IP is @ip
:
:
:
: END
Try taking out all the HTML tags first. See if you can get the right IP by just running the script from the command line. Once it works on command line, then add your HTML and everything should be fine.
The only thing I see is place a print in front of "Your IP is $ip";
X
Don't know if that'll fix it but it was something I noticed.
: I am trying to write a script that shows the IP of incoming request. The code works, but gives me a wrong IP which it gets from I don’t know were. I am running this code on tripod. Any idea why this shouldn’t work?
:
: #!/usr/local/bin/perl
:
: my @ip = ($ENV{REMOTE_ADDR});
:
: print <<END;
:
: Content-Type: text/html
:
:
: <html>
:
: Your IP is @ip
:
:
:
: END
: