?
Solved

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

Posted on 2004-11-30
10
Medium Priority
?
216 Views
Last Modified: 2013-12-25
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;
}

---------------------------------
0
Comment
Question by:dsmark111
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12710601
use Win32API::File;
0
 

Author Comment

by:dsmark111
ID: 12710708
thanks, but that doesn't work
0
 
LVL 48

Expert Comment

by:Tintin
ID: 12711116
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
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 

Author Comment

by:dsmark111
ID: 12763768
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
 
LVL 48

Expert Comment

by:Tintin
ID: 12769225
Does your *webserver* have access to that share?
0
 

Author Comment

by:dsmark111
ID: 12842214
Yes, could it be a windows 2003 security setting?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 12844752
Not very familar with Windows permissions.
0
 
LVL 2

Expert Comment

by:rustycp
ID: 12954061
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
 
LVL 2

Accepted Solution

by:
rustycp earned 1500 total points
ID: 12954202
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question