Energon
02-22-2002, 07:33 PM
I hate to ask a question about IIS here, but I don't know for sure if it's ActivePerl or IIS that's being the problem.
I've got this CGI script here, and it runs dandily great on my Linux machine with Apache. But when we transfer it over to the actual IIS machine (running the latest ActivePerl build), the calls to open() fail (I'm writing some data to a file from a form). Here's the relevant portions of the script:
#! /usr/bin/perl -w
use strict;
use CGI qw(param);
#
# GLOBAL VARIABLES
#
# set this to where form results will be saved (this file must exist and be writable by the server user)
my $savefile = "C:\\InetPub\\wwwroot\\tech\\results.txt";
# the page to return to
my $returnpage = "http://www.kunaschools.org/tech/classes/default.htm";
#
# FUNCTIONS
#
# prints parameters to a file
sub write_file
{
# open the file (create it if necessary
unless(-e $savefile) {
unless(open(RESULTFILE, ">$savefile")) {
error "Could not create results file (results not saved)";
return 0;
}
} else {
unless(open(RESULTFILE, ">>$savefile")) {
error "Could not open results file (results not saved)";
return 0;
}
}
# print the results
select(RESULTFILE);
select(STDOUT);
# close the file
unless(close(RESULTFILE)) {
error "Could not close results file (results not saved)";
return 0;
}
return 1;
}
# the main function
sub main
{
# write the file and confirm if that was successful
confirmation if(write_file);
}
# print the content header and run main
print "Content-type: text/html\n\n";
main;
We had to create the file by hand, and it does see it, but the call to open errors out (I print "Could not open file" instead of "Could not create file".
The system is on Fat32, so I can't see how it's a permission problem, so is there something about Perl not liking open() in Windows, or did we misconfigure IIS and script permissions?
I've got this CGI script here, and it runs dandily great on my Linux machine with Apache. But when we transfer it over to the actual IIS machine (running the latest ActivePerl build), the calls to open() fail (I'm writing some data to a file from a form). Here's the relevant portions of the script:
#! /usr/bin/perl -w
use strict;
use CGI qw(param);
#
# GLOBAL VARIABLES
#
# set this to where form results will be saved (this file must exist and be writable by the server user)
my $savefile = "C:\\InetPub\\wwwroot\\tech\\results.txt";
# the page to return to
my $returnpage = "http://www.kunaschools.org/tech/classes/default.htm";
#
# FUNCTIONS
#
# prints parameters to a file
sub write_file
{
# open the file (create it if necessary
unless(-e $savefile) {
unless(open(RESULTFILE, ">$savefile")) {
error "Could not create results file (results not saved)";
return 0;
}
} else {
unless(open(RESULTFILE, ">>$savefile")) {
error "Could not open results file (results not saved)";
return 0;
}
}
# print the results
select(RESULTFILE);
select(STDOUT);
# close the file
unless(close(RESULTFILE)) {
error "Could not close results file (results not saved)";
return 0;
}
return 1;
}
# the main function
sub main
{
# write the file and confirm if that was successful
confirmation if(write_file);
}
# print the content header and run main
print "Content-type: text/html\n\n";
main;
We had to create the file by hand, and it does see it, but the call to open errors out (I print "Could not open file" instead of "Could not create file".
The system is on Fat32, so I can't see how it's a permission problem, so is there something about Perl not liking open() in Windows, or did we misconfigure IIS and script permissions?