perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <sbek...@stason.org>
Subject Re: test for mod_perl? for IIS?
Date Thu, 01 Jun 2000 10:59:22 GMT
> I'm working on a project that has been running as CGI on Netscape and
> IIS. We were told to port to mod_perl on Apache. Now it seems we must
> also run on CGI on IIS and on Apache: three platforms total.
> 
> Testing $ENV{'GATEWAY_INTERFACE'} allows us to detect CGI, but
> (correct me if I'm wrong) not whether that CGI is on Apache or IIS.
> What I'd like to know is the "right way" to test, from within a script,
> 
> * whether one is running under mod_perl? Currently we're doing
> 
> > if($ENV{'GATEWAY_INTERFACE'} =~ /^CGI-Perl\//) {
> > 	$MOD_PERL = 1;
> > } else {
> > 	$MOD_PERL = 0;
> > }
> 
> * whether one is running under IIS?
> 
> Please reply directly to me as well as the list/group (I subscribe the
> digest), and TIA, Tom_Roche@ncsu.edu 

Try:

#!/usr/bin/perl
print "Content-type: text/plain\r\n\r\n";
print join "\n", @INC, "\n";
for (keys %ENV){
  print "$_ => $ENV{$_}\n";
}

Based on the results from the above script:
* mod_perl test: do {} if $ENV{MOD_PERL};
* Apache test  : do {} if $ENV{SERVER_SOFTWARE} =~ /Apache/;

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:stas@stason.org   http://perl.org     http://stason.org/TULARC
http://singlesheaven.com http://perlmonth.com http://sourcegarden.org


Mime
View raw message