Perl write file in the website root directory instead of script directory

Posted by on 2014-09-02 04:47


Here is my issue with my Perl / IIS7 configuration.

My website is configured to be launched in the E:\WEBSITE\TOTO\HTML windows directory.
I have a subfolder HTML\user_report where my Perl script ( is located. This script is supposed to create a file report.txt in the same folder.

But when I launch http://Mywebsite/user_report/ the report.txt is created in E:\WEBSITE\TOTO\HTML\report.txt instead of E:\WEBSITE\TOTO\HTML\user_report\report.txt.

Does any one have an idea ?

Here is the

# writeproject
# this is the CGI that will take the # applet info and write it to project.tmp

print "content-type: text/plain\n\n";
use strict;
use warnings;

my $filename = 'report.txt';
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh "My first report generated by perl\n";
close $fh;
print "done\n";

The server is Windows 2008 R2 64bits
IIS 7.5
Perl 5.15

Thanks for any advice.

guillaume.donni... | Tue, 2014-09-09 08:23


Does anyone have any idea about my problem ?