[ back to toc ]

perl 5: file I/O through IIS

Date: 2002/03/06 12:09

I am new to Perl, and am having a blast with it. However, I am at a
standstill. I get different results between running perl on the command
line and going through IIS (not ISAPI). The command line use acts as
expected. The IIS use runs, but, will not open files successfully:

A 15 line perl file, test.cgi, is as follows:

print "Contents-type: text/html","\n\n";
print "<html><body>\n";
print "Comparing FILE I/O through Perl
on command line and with IIS<br>\n";
if( open(FILE, '< test.dat')) {
print "true\n";
} else {
print "false\n";
close FILE;
for ( $i=0 ; $i<$filesize ; $i++ ) {
print "</body></html>";

A 3 line data file, test.dat, is as follows:

This is a
data, data, data...

If I run 'test.cgi' with perl on the command line, it produces the
expected result:

D:\Inetpub\cgi-bin\wiki>perl test.cgi
Contents-type: text/html

Comparing FILE I/O through Perl on command
line and with IIS<br>
0:This is a
2:data, data, data...

When run test.cgi through the browser, it runs, but, the data file can't
be opened.

Comparing FILE I/O through Perl on command
line and with IIS

The OS is MsWin2k Pro v5.00.2195. The 'website' permissions for the
directory containing the two files are set for 'Read' and 'Script

I'm stumped. Any Ideas?
Thanks in advance.

Never use relative file names in a CGI script, like test.dat. Allways
specify the full path.

CGI standard does not define what the current working directory is.

Under IIS the current working directory is virtual directory root, in cour
case D:\Inetpub\cgi-bin and the program it starts wiki\test.cgi

Under Apache assuming the same configuration it would be

Under Netscape web server the current working directory (on UNIX) is where
the system manager started the server. Usually /

Thus specify the full path name.


[ back to toc ]