SHARE
Facebook X Pinterest WhatsApp

ISAPI Perl Workaround for Unix Conventions Page 6

Jul 20, 2010
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



Since ISAPI Perl honors neither of these conventions, workarounds must be provided. The workaround for the first line of the Perl script convention is that ISAPI Perl is associated with a file extension when ActiveState Perl was first installed. Thus, to run a CGI script under ISAPI Perl, the script should match the ISAPI Perl file extension specified when the ActiveState Perl installation program was run.

IIS and ISAPI Perl also have a problem recognizing the current working directory of a script. There are two ways around this problem: Give a hint to the Web server to let it know the current working directory of the script, or tell the script itself what the absolute path is to all the programs.

The easiest way to solve the problem is to provide a simple “hint” to the Web server about the current working directory in which the script should run. It turns out that IIS is not entirely clueless with regard to the path: It just needs a push in the right direction.

Setting up a Virtual Root on the IIS Server provides this “push.” In the IIS management console, Virtual Roots essentially map a URL directory name to a physical directory on your machine. One of the default virtual roots is /cgi-bin — which may
point to a directory such as:

c:inetpubwwwrootcgi-bin

The tricky thing is that any scripts under that /cgi-bin virtual root are forced by IIS to use c:inetpubwwwrootcgi-bin as the current working directory regardless of whether the script itself lies in a subdirectory.

To get around this problem, create a virtual root that points to the actual directory that the script lies in. For example, to create a virtual root to a calendar script, you might consider calling the virtual root /calendar-bin, and have it point
directly to

c:inetpubwwwrootcgi-bincalendar

If you have many scripts, however, adding virtual roots all the time can be a pain. To make it less odious, you might consider either modifying all the paths in the script to use absolute directory references or add a chdir() command to the top of the script.

The chdir() command is usually an easier solution, as it allows the script to maintain references to all data files and libraries using relative path references. The chdir command for the example above would be:

chdir("c:/inetpub/wwwroot/cgi-bin/calendar/");

Remember, if you choose to use the MS-DOS convention of separating path names using the
backslash, then you must escape the backslash when using Perl. The above chdir command using backslashes would look like the following:

chdir("c:inetpubwwwrootcgi-bincalendar");
thumbnail Gunther Birznieks

Gunther Birznieks is a ServerWatch contributor.

Recommended for you...

What Is a Container? Understanding Containerization
What Is a Print Server? | How It Works and What It Does
Nisar Ahmad
Dec 8, 2023
What Is a Network Policy Server (NPS)? | Essential Guide
Virtual Servers vs. Physical Servers: Comparison and Use Cases
Ray Fernandez
Nov 14, 2023
ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.