Home: Perl Programming Help: Win32 Programming Help:
Solution to IIS relative paths, compatible



yapp
User

Oct 17, 2001, 11:47 PM


Views: 7662
Solution to IIS relative paths, compatible

OK, I've posted this code is some other topics aswell. I think it's very important everone knows about this.

Most comlex scripts fail running under IIS with relative paths or require 'file' files. Most of the time, a 'can't locate at @INC', or 'file not found' message appears (or is written in the error log). This is because the current directory in IIS is the WWW-root. I've seen a solution to this problem in the code of a different BB system.

Here it is:

Code
BEGIN{ 
$THIS_PATH = 'current-directory-you-specified';
if($ENV{'SERVER_SOFTWARE'} =~ /IIS/) {
push @INC, $THIS_PATH;
chdir($THIS_PATH);
}
}

...

# This all works now!!!

require 'morecode.pl';
open('file.txt') or die ....

Hope it helps... (well, it worked for me)


P.S. Currently, I'm developing a bunch of mudules for this.
XProgramming::CGI::Location; // auto detects location of CGI + IIS bugfix
XProgramming::CGI::ErrorTrap; // handle errors better, with personal dialogs
XProgramming::CGI::Template; // template parser
And so on.
They are available as single download at this moment, , available from http://www.cool-programming.f2s.com


I've posted this topic in the Immediate Subject first, but I realized it should be posted herre.



yapp
User

Oct 17, 2001, 11:48 PM


Views: 7661
Re: Solution to IIS relative paths, compatible

Sorry, I guess something got wrong with posting. I thought my previous post failed in this topic.