You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tom Roche <to...@ncsu.edu> on 2000/06/01 07:30:21 UTC

test for mod_perl? for IIS?

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 


Re: test for mod_perl? for IIS?

Posted by Stas Bekman <sb...@stason.org>.
> 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