problem in opening a network directory in CGI - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

problem in opening a network directory in CGI

snitchsnitch Posts: 13Member
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

Comments

  • JonathanJonathan Posts: 2,914Member
    : 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.");

  • snitchsnitch Posts: 13Member
    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.");
    :
    :
  • JonathanJonathan Posts: 2,914Member
    : 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.");

  • snitchsnitch Posts: 13Member
    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.");
    :
    :
  • JonathanJonathan Posts: 2,914Member
    : 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.");

Sign In or Register to comment.