# problem in opening a network directory in CGI

Hi there,
I have the following sinppet of code

#!C:Perlinperl.exe

print "Content-type: text/html

";

print "";
print "";
print "Contents of directory";
print "";
print "";

$dir='\\\abc\def\'; if(!opendir(DIR,$dir);){
print "Can't Open Directory $dir"; closedir DIR; die; } @dots = readdir(DIR); foreach (@dots){ print "$_
";
print "
";
}

closedir DIR;

This fails and it flags an error sayin it cannot open the directory.
The same thing works fine wen executed on command prompt .
but we try in HTML it is not working ..
also tried mapping the n/w to a drive and opening it again it fails ...

n e clues ???

curcio
snitch

• : Hi there,
: I have the following sinppet of code
:
: #!C:Perlinperl.exe
:
: print "Content-type: text/html

";
:
: print "";
: print "";
: print "Contents of directory";
: print "";
: print "";
:
: $dir='\\\abc\def\'; : : if(!opendir(DIR,$dir);){
: print "Can't Open Directory $dir"; : closedir DIR; : die; : } : @dots = readdir(DIR); : foreach (@dots){ : print "$_
";
: print "";
: }
:
: closedir DIR;
:
: This fails and it flags an error sayin it cannot open the directory.
: The same thing works fine wen executed on command prompt .
: but we try in HTML it is not working ..
: also tried mapping the n/w to a drive and opening it again it fails ...
:
: n e clues ???
:
If it works at the command line but not as a CGI script I'd reckon it's a permissions issue. Figure out what user the script runs as when running as a CGI, and grant that user the required permissions to access the network and other network drives as needed.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

• Well even i thought so ...
but I am working in windows 2000 environment with IIS 4.0 installed.
don't hav a clue abt the problem.

curcio,
snitch

: : Hi there,
: : I have the following sinppet of code
: :
: : #!C:Perlinperl.exe
: :
: : print "Content-type: text/html

";
: :
: : print "";
: : print "";
: : print "Contents of directory";
: : print "";
: : print "";
: :
: : $dir='\\\abc\def\'; : : : : if(!opendir(DIR,$dir);){
: : print "Can't Open Directory $dir"; : : closedir DIR; : : die; : : } : : @dots = readdir(DIR); : : foreach (@dots){ : : print "$_
";
: : print "";
: : }
: :
: : closedir DIR;
: :
: : This fails and it flags an error sayin it cannot open the directory.
: : The same thing works fine wen executed on command prompt .
: : but we try in HTML it is not working ..
: : also tried mapping the n/w to a drive and opening it again it fails ...
: :
: : n e clues ???
: :
: If it works at the command line but not as a CGI script I'd reckon it's a permissions issue. Figure out what user the script runs as when running as a CGI, and grant that user the required permissions to access the network and other network drives as needed.
:
: Jonathan
:
:
: ###
: for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
: (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
: /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
:
:
• : Well even i thought so ...
: but I am working in windows 2000 environment with IIS 4.0 installed.
: don't hav a clue abt the problem.
:
I guessed. I've previously worked in that environment too, and I remember having to spend time on a number of occasions with the NT sysadmin getting file privs set up so my script could access files in places we wanted it to. The default is that it can't. You need to explicitly set this up.

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

• I tried ... but can't figure it out where i have to set it ...
and am the sys admin here ...
so can ya pls guide where i can set it ???

curcio
snitch
: : Well even i thought so ...
: : but I am working in windows 2000 environment with IIS 4.0 installed.
: : don't hav a clue abt the problem.
: :
: I guessed. I've previously worked in that environment too, and I remember having to spend time on a number of occasions with the NT sysadmin getting file privs set up so my script could access files in places we wanted it to. The default is that it can't. You need to explicitly set this up.
:
: Jonathan
:
: ###
: for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
: (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
: /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
:
:
• : I tried ... but can't figure it out where i have to set it ...
: and am the sys admin here ...
: so can ya pls guide where i can set it ???
It's just set up as file access permissions normally are. You just need to find what user the script runs as - I can't remember the user name you are looking for but it may be something like wwwuser. Once you find that you need to give that user permissions to read (and/or write, etc) the share you want them to have access to. Just like you grant any normal user permissions.

I ain't an NT sys admin, I just watched. :-)

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");