Newbie: problems with chdir & opendir() 
Author Message
 Newbie: problems with chdir & opendir()

Hi all,

I am a newbie to Perl and need some urgent help.

I am trying to get a list of files stored on a network server. I am
using ActivePerl & WinNT4.

I am trying to change to the folder, either with UNC or via the shared
drive letter(with chdir) but with no luck.

The weird thing is that the code below works fine from the command
line, but as soon as I use it through a browser (IE 5.5 & NN 4.7) it
mis-behaves.

When run through a browser it produces a list of files in the current
working folder on my C: drive and not the remote folder.

What am I doing wrong ?

Sample Code:
$name = "V:/somefolder/";
chdir("V:/somefolder");

opendir(DIR, $name)
    or die "Can't open $name due to $!";

$entry = readdir(DIR);

while ( defined($entry) ) {

    print "$entry\n";

    # Get next entry.
    $entry = readdir(DIR);

Quote:
}

# Close directory handle when done.
closedir(DIR);

Thanks in Advance

David



Mon, 17 May 2004 14:05:04 GMT  
 Newbie: problems with chdir & opendir()


Quote:
> I am trying to get a list of files stored on a network server. I am
> using ActivePerl & WinNT4.
[SNIP]
> The weird thing is that the code below works fine from the command
> line, but as soon as I use it through a browser (IE 5.5 & NN 4.7) it
> mis-behaves.

That's because in the console the script runs under your user id,
that's allowed to access the server. When started as a CGI the script
runs under the user id of the web server, wich isn't allowed to
access the server via the shared drive letter...

So the real problem is the remote server rejecting the connection
not perl...

HTH,   Chris



Mon, 17 May 2004 14:15:45 GMT  
 Newbie: problems with chdir & opendir()


Quote:
> Hi all,

> I am a newbie to Perl and need some urgent help.

> I am trying to get a list of files stored on a network server. I am
> using ActivePerl & WinNT4.

> I am trying to change to the folder, either with UNC or via the shared
> drive letter(with chdir) but with no luck.

> The weird thing is that the code below works fine from the command
> line, but as soon as I use it through a browser (IE 5.5 & NN 4.7) it
> mis-behaves.

> When run through a browser it produces a list of files in the current
> working folder on my C: drive and not the remote folder.

> What am I doing wrong ?

> Sample Code:
> $name = "V:/somefolder/";
> chdir("V:/somefolder");

chdir "V:/somefolder" or die "Can not chdir to V:/somefolder $!\n";


Mon, 17 May 2004 22:32:07 GMT  
 Newbie: problems with chdir & opendir()

Quote:
> > I am trying to get a list of files stored on a network server. I am
> > using ActivePerl & WinNT4.
> [SNIP]
> > The weird thing is that the code below works fine from the command
> > line, but as soon as I use it through a browser (IE 5.5 & NN 4.7) it
> > mis-behaves.

> That's because in the console the script runs under your user id,
> that's allowed to access the server. When started as a CGI the script
> runs under the user id of the web server, wich isn't allowed to
> access the server via the shared drive letter...

> So the real problem is the remote server rejecting the connection
> not perl...

> HTH,   Chris

Chris,

That makes sense.....

I know this probably isnt the NG to post this but maybe you can help me....

How do I change my web server's ID to access the remote folder ?

if not, which NG should I post this to ?

Many thanks

David



Mon, 17 May 2004 22:55:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. system() && threads and chdir() && threads

2. HELP: Newbie opendir question

3. SUMMARY: Problem with chdir under Ultrix

4. Problem with chdir under Ultrix

5. problem with chdir

6. problems with chdir

7. Win32 and chdir problems

8. chdir in UNIX: problem with the ~

9. Problem with chdir

10. chdir("A:\\"); problem

11. Newbie Question: XML::Parser & Expat build problems

12. stupid opendir() problem...

 

 
Powered by phpBB® Forum Software