in reply to Using CGI (Perl) and javascript at the same time
OK... let me get out my Acme® brand flashlight here. When I run a script that basically just dumps all the elements of the %ENV hash on my server here is a sanitized version of what I get back:
DOCUMENT_ROOT /path/to/doc/root/www.mydomain.com GATEWAY_INTERFACE CGI/1.1 HTTP_ACCEPT text/xml,application/xml,application/xhtml+xml,text/ht +ml;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif; +q=0.2,*/*;q=0.1 HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7 HTTP_ACCEPT_ENCODING gzip,deflate HTTP_ACCEPT_LANGUAGE en-us,en;q=0.5 HTTP_CONNECTION keep-alive HTTP_HOST www.mydomain.com HTTP_KEEP_ALIVE 300 HTTP_USER_AGENT Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) +Gecko/20040301 PATH /usr/local/bin:/usr/bin:/bin QUERY_STRING REMOTE_ADDR 4.3.2.1 REMOTE_PORT 33161 REQUEST_METHOD GET REQUEST_URI /cgi-bin/fooCheck.pl SCRIPT_FILENAME /usr/web/www.berghold.net/cgi-bin/fooCheck.pl SCRIPT_NAME /cgi-bin/fooCheck.pl SERVER_ADDR 1.2.3.4 SERVER_ADMIN webmaster@mydomain.com SERVER_NAME www.mydomain.com SERVER_PORT 80 SERVER_PROTOCOL HTTP/1.1 SERVER_SOFTWARE Apache/1.3.29 (Unix) AuthMySQL/2.20 PHP/4.3.4 mod_ +perl/1.24 mod_ssl/2.8.16 OpenSSL/0.9.7c UNIQUE_ID QHMCUdiLkw8AAAVExU8
A quick glance reveals a value for REMOTE_ADDR which when I check the NAT'ed address for my client what I see there matches what I know my NAT'ed IP address to be.
If you are interested here is a subset of the code that generated that output:
use CGI qw(:all); print header,start_html; env_test(); print end_html; exit(0); sub env_test { print h2('Base Account (shell) Environment'); print table( map { Tr(td($_),td($ENV{$_})) } sort keys %ENV ); print p(b('CGI Runs As:'),`id`); print p(b('Current working directory is:'),`pwd`); print p("I was invoked as: ",$0); if ($ENV{HOME}) { if (-d $ENV{HOME} . '/cgi-bin') { print p('Found the cgi-bin directory in ', $ENV{HOME} . "/cgi-bi +n"); } else { print p("I have no clue where the cgi-bin is physically"); } } else { print p(b('OH DRAT!'),'The $HOME variable is not being set!'); } }
|
|---|