Darrenme has asked for the wisdom of the Perl Monks concerning the following question:

I have written a script that captures the environment variable REMOTE_HOST. This worked fine until I moved servers and it no longer returns a value.

Can anyone help ?

Darren

Edit by tye

  • Comment on $ENV{REMOTE_HOST} not set on new server?

Replies are listed 'Best First'.
Re: REMOTE_HOST
by tachyon (Chancellor) on Oct 25, 2001 at 16:33 UTC

    Run this script to have a look at your environment:

    #!/usr/bin/perl -wT use strict; print "Content-type: text/html\n\n"; print "<p><b>$_</b><br>$ENV{$_}\n" for sort keys %ENV;

    What I expect you will find is the REMOTE_ADDR contains a value but REMOTE_HOST does not. This occurs because reverse DNS lookups need to be enabled on the server to allow your server to convert REMOTE_ADDR into a hostname.

    You should be able to convert REMOTE_ADDR into a hostname yourself using gethostbyaddr():

    use Socket; $iaddr = gethostbyname('www.perlmonks.com'); $name = gethostbyaddr($iaddr, AF_INET); print $name;

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: REMOTE_HOST
by graq (Curate) on Oct 25, 2001 at 12:52 UTC
    This is unlikely to be a Perl problem.
    edit Which is probably why the question has a low reputation - don't be discouraged! /edit

    REMOTE_HOST is usually set by the Web Server
    For example, from Apache HostName LookUps

    So you will need to be aware of the change in web server configuration.
    There is an outside chance that if you have moved machines that the DNS is different and the lookup is failing. But that is not so likely.

    As busunsl stated, more details are required.

    <a href="http://www.graq.co.uk">Graq</a>

Re: REMOTE_HOST
by busunsl (Vicar) on Oct 25, 2001 at 12:13 UTC
    Since the script hasn't changed it seems to be the server.

    Tell us a bit more about the environment:

    Server, OS, Versions of all, etc.