in reply to Perl and Shared drive
Your question is a little vague. If you are trying to write you script so that other people can run the script on their computer without having to modify it, then you need to refer to the file by its network path. Instead of referring to the mapped drive name use the share name.
Example
'\\\\ComputerName\\DirName\\Filename' or
'//ComputerName/Dirname/Filename'
Here is some example code I tested on my computer of different ways to access the data.
#! /usr/bin/perl -w # Different ways to open file on another networked windows machine. # Assume: Other computers name is Zoe # The file is in the shared directory zoe_data\test # The directory zoe_data has been mapped localy to F: # The filename is test.txt @mypaths = ( '\\\\Zoe\\zoe_data\\test\\', 'F:\\test\\', '//Zoe/zoe_data/test/', 'F:/test/' ); $filename = "test.txt"; foreach $path (@mypaths) { print "\n\nOpening file [", $path . $filename, " ]\n\n"; open (IN,$path . $filename) or die "can't open the file: $!\n"; print while (<IN>); close (IN); }
I hope this answers your question.
zzspectrez
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Perl and Shared drive
by Anish (Novice) on Nov 07, 2000 at 02:32 UTC | |
by zzspectrez (Hermit) on Nov 07, 2000 at 09:33 UTC |