For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Accessing a remote folder









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Accessing a remote folder
ytoledano@gmail.com

2006-01-10, 4:02 am

How do I create a handle to a remote file, like \\IP\c\file.txt?
(Without mapping a network drive)

Can I use opendir on a remote folder?

ben.j.pearce@gmail.com

2006-01-10, 4:02 am

The opendir and other file access functions seem to pass the request
through the OS and let it deal with it.

I have used perl to read remote files and directories with no problems.

As long as the security account that you are running the perl script as
has access to the requested resource then you should have no problems


#read directory list of *.log files
opendir(DIR, "$dir");
@files = grep(/\.log$/,readdir(DIR));
closedir(DIR);

works for remote and local directories

Cheers
Ben

ytoledano@gmail.com

2006-01-10, 4:02 am

Thanks.

How do I create the connection to the file? will this work:

open LOG1, $files[0];

ben.j.pearce@gmail.com

2006-01-10, 4:02 am

As long as $files[0] contains the filename and full path (remote or
local)

Then use <LOG1> the read from the file

Ben

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com