Gossamer Forum
Home : General : Perl Programming :

$ENV{'REMOTE_HOST'}

Quote Reply
$ENV{'REMOTE_HOST'}
Hi,

My host just changed my server and now this variable $ENV{'REMOTE_HOST'} doesn't give anything back. Is it something they need to set up properly on their end?

This $ENV{'REMOTE_ADDR'} does work!

Thanks!
Adam

Quote Reply
Re: $ENV{'REMOTE_HOST'} In reply to
And now all works! I think it had to do with a switch for my access logs, but I don't really know....oh well.


Quote Reply
Re: $ENV{'REMOTE_HOST'} In reply to
REMOTE_HOST only shows up if your server has dns lookups turned on, otherwise you can get the IP address from REMOTE_ADDR.

They must have switched it back on. =)

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: $ENV{'REMOTE_HOST'} In reply to
But of course it is no problem to resolve a visitors' IP address within a single script by using the gethostbyaddr function. One example:

#!/usr/local/bin/perl
use Socket;
$ip = $ENV{'REMOTE_ADDR'};
$hostname = scalar(gethostbyaddr(inet_aton($ip), AF_INET));
print "Content-type: text/html\n\n";
print $ip." - ".$hostname;

Just include 2 to 3 in your script and it should work fine.

Quote Reply
Re: $ENV{'REMOTE_HOST'} In reply to
Yes Alex, you are correct. Actually I had to switch it on by adding a blank file called dns to one of my directories. Then wait a few hours....then it kicked in!

Thanks,
Adam