The question was specifically about CGI. As part of the CGI specification, you'll see that some environmental variables are specifically set for every request. (including the two I mentioned originally)

It's always possible that some of the other more-than-just-CGI implementations (FastCGI, mod_perl, etc), behave differently, as well as software that doesn't correctly implement the CGI specifications.

However, for my install of mod_perl (using Apache::Registry, Apache 1.3, Mac OS X), in using the following simple script:

#!/usr/bin/perl -- use Data::Dumper; print "Content-Type: text/plain\n\n", Dumper \%ENV;

I get after censoring out the host name:

$VAR1 = { 'SCRIPT_NAME' => '/cgi/test-cgi', 'SERVER_NAME' => '[censored]', 'SERVER_ADMIN' => '[no address given]', 'PERL_SEND_HEADER' => 'On', 'REQUEST_METHOD' => 'GET', 'SCRIPT_URI' => 'http://[censored]/cgi/test-cgi', 'SCRIPT_FILENAME' => '/Library/Webserver/Mod_Perl-Executable +s/test-cgi', 'SERVER_SOFTWARE' => 'Apache/1.3.33 (Darwin) mod_perl/1.29', 'QUERY_STRING' => '', 'REMOTE_PORT' => '53739', 'SERVER_SIGNATURE' => '<ADDRESS>Apache/1.3.33 Server at [cen +sored] Port 80</ADDRESS> ', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'SERVER_PROTOCOL' => 'HTTP/1.0', 'PATH' => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/Syste +m/Library/CoreServices', 'REQUEST_URI' => '/cgi/test-cgi', 'GATEWAY_INTERFACE' => 'CGI-Perl/1.1', 'SCRIPT_URL' => '/cgi/test-cgi', 'SERVER_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'MOD_PERL' => 'mod_perl/1.29' };

You'll notice that 'GATEWAY_INTERFACE' is still defined, and indicates that it's not a standard CGI.

Using Apache::PerlRun is the almost identical:

$VAR1 = { 'SCRIPT_NAME' => '/perl/test-cgi', 'SERVER_NAME' => '[censored]', 'SERVER_ADMIN' => '[no address given]', 'PERL_SEND_HEADER' => 'On', 'REQUEST_METHOD' => 'GET', 'SCRIPT_URI' => 'http://[censored]/perl/test-cgi', 'SCRIPT_FILENAME' => '/Library/Webserver/Mod_Perl-Executable +s/test-cgi', 'SERVER_SOFTWARE' => 'Apache/1.3.33 (Darwin) mod_perl/1.29', 'QUERY_STRING' => '', 'REMOTE_PORT' => '53741', 'SERVER_SIGNATURE' => '<ADDRESS>Apache/1.3.33 Server at [cen +sored] Port 80</ADDRESS> ', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'SERVER_PROTOCOL' => 'HTTP/1.0', 'PATH' => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/Syste +m/Library/CoreServices', 'REQUEST_URI' => '/perl/test-cgi', 'GATEWAY_INTERFACE' => 'CGI-Perl/1.1', 'SCRIPT_URL' => '/perl/test-cgi', 'SERVER_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'MOD_PERL' => 'mod_perl/1.29' };

In reply to Re^4: Telling if your script is running from web page or CLI by jhourcle
in thread Telling if your script is running from web page or CLI by dizzyg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.