Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read dir on remote server?

Status
Not open for further replies.

loosecannon1

Programmer
Feb 19, 2002
55
US
I'm trying to access files on a remote server and the opendir function is is failing. I'm certain the dir path is correct. Following is my code. Any ideas???????

$Dir = "
opendir(DIR,$Dir) || die "Can't open $Dir";
@fileNames = readdir(DIR);
closedir (DIR);

for (@fileNames) {
next if $_ eq '.';
next if $_ eq '..';
next if $_ eq '...';
print "$_\n";
}
 
Nope, works fine on my local LAN, except my path of course different.

$dir = "\\\\server\\share_name";
 
I don't think [red]opendir/readdir[/red] will work over a web connection.
I think you need a local network mapped/mappable drive to hit with opendir/readdir.

You could use the LWP module to hit a web page and retrieve it.

Code:
#!/usr/local/bin/perl
use LWP::Simple;
$Dir = "[URL unfurl="true"]http://iwqatest.iddedit.com/usr/ns-home/iwqa-docs/tc/handouts/";[/URL]
$content = get($Dir);

# parse the IMG SRC tags from the HTML 
while ($content =~ /<a href=&quot;(.*?)&quot;>/gis)
    {
    # list each sub-dir 
    print &quot;Found $1\n&quot;;
    }

I have not run this, but it should be close to working and hopefully
illustrates the basic approach. For more info on the LWP module, see
prompt>perldoc LWP -enter-
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top