perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maurice McCabe" <mmcc...@orbsoft.com>
Subject IIS PATH_TRANSLATED fix
Date Fri, 02 Jul 2004 23:48:46 GMT
I am installing on a shared Windows Server running IIS and want to be
able to run embpcgi.pl as a regular CGI script (no file extension
mapping is available, since not supported in this ISP's shared
environment). By default, in CGI mode, IIS does not generate the correct
value for PATH_TRANSLATED, so I created a fix that gets around the
problem that I would like to share.

Adding the following to your embpcgi.pl will allow you to run on IIS
using a URL like:
http://www.mycompany.com/cgi-bin/embpcgi.pl/myembperlapplication/index.h
tm
(This fix still behaves correctly when using file extension mapping
allowing you to run in either mode)

BEGIN {
    if ($^O eq "MSWin32" && $#ARGV == -1) {
        my $SCRIPT_FILENAME=$0;
        my ($path_info) = $ENV{PATH_INFO} =~ /^$ENV{SCRIPT_NAME}(.*)$/;
        my $SCRIPT_NAME = $ENV{SCRIPT_NAME};
        $SCRIPT_NAME =~ s/\//\\\\/g;
        my ($document_root) = $SCRIPT_FILENAME =~ /^(.*)$SCRIPT_NAME.*/;
        $ENV{PATH_TRANSLATED}=$document_root . $path_info;
    }
}

This fix is not restricted for use with Embperl or even with Perl (may
involve more coding if rewritten in another language). It should work
for any CGI application running on IIS that uses PATH_TRANSLATED.

Hope this helps some folks out there that have been looking for this. 

BTW: With this fix, I can confirm that Embperl will run in a shared
Windows environment running IIS and Perl. (Requires only FTP and setting
of @INC to install. Must have precompiled non-modperl version of Embperl
for windows available from Randy Kobes)

Maurice


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message