Windows 2003 and IIS 6 - Using CGI to access remote file on network

I am trying to get CGI to open and read from a file on the network.    I have looked everywhere to fix this problem, maybe you can help me fix it. Thanks in advance!!

I am using windows 2003 server with IIS 6 enabled.
I have installed and configured Perl to run using the Perl ISAPI extension.  
C:\Perl\bin\perlis.dll

Extensions .pl and .cgi are mapped to open using perlis.dll

I have no problem getting cgi scripts to run scripts and interact with data locally.
The problem occurs when I try to interact with files that are on the network.  I believe it is a security issue with windows 2003.  I even made a network share with security setting of "everyone" with full access; still the cgi script couldn't open the file.

What security options do I have to open for cgi scripts to access networked shares?

When I run this code to access locally, it works.
---------------------------------

snippet
......

my $data_file = "d:\\data\\program_data.txt";
   
my $DATA = open(DATA,$data_file);
if(!$DATA) {
    print "can't open: $data_file \n";
    exit 1;
}

---------------------------------

Here, I put the file on the network share, that has "everyone" with full access.  It prints the error message: can't open: \\ServerA221\Data\program_data.txt. However, in IE, when I type in: \\ServerA221\Data\program_data.txt, it opens

snippet
......

my $data_file = "\\\\ServerA221\\Data\\program_data.txt";
   
my $DATA = open(DATA ,$data_file);

if(!$DATA )

{
    print "can't open: $data_file\n";
    exit 1;
}

---------------------------------
dsmark111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
use Win32API::File;
0
dsmark111Author Commented:
thanks, but that doesn't work
0
TintinCommented:
Using backslashes just gets confusing (Also your open call is "unique")

my $data_file = "//ServerA221/Data/program_data.txt";
open DATA, $data_file or die "Can not open $data_file $!\n";

Also, add:

use CGI::Carp qw(fatalsToBrowser);

At the top of your script to be able to see any errors in the browser rather than getting a "500 internal server" error and hunting in the web server errors logs.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

dsmark111Author Commented:
I get this error:

Content-type: text/html
Software error:
Cannot open //ServerA221/Data/program_data.txt Invalid argument

For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.
0
TintinCommented:
Does your *webserver* have access to that share?
0
dsmark111Author Commented:
Yes, could it be a windows 2003 security setting?
0
TintinCommented:
Not very familar with Windows permissions.
0
rustycpCommented:
coudl you try executing the perl script from the command line, outside of the web server, to see if it accesses the file?  Then you'll know if it has anything to do with running as a CGI script or not.
0
rustycpCommented:
Try mapping a directory, such as making \\dataserver the same as "s:", then try it using the directory letter.  Here's an example:

#$file='\\dataserver\shared\test.txt'; # Didn't work for me
#$file='\\192.168.1.54\shared\test.txt'; # Didn't work for me
$file='G:\shared\test.txt'; # DID work for me

open (F,"<$file") || print $!;
while (<F>){
      print $_;
}
close F;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.