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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File I/O using Mapped drives on NT 1

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
VN
Hey there,

I am trying to add a little extra functionality to a script i have written which will copy a file from a local file to a location on another NT machine (on the same domain), the permissions are set to allow 'everyone' to write to the target folder(and file), but I don't get past the file test line that checks the target location exists.

Code
~~~~
use File::Copy;
$mirrorroot = "y:/wtw/experiment";
if (-d $mirrorroot) { print header; print "Mirror root found! at $mirrorroot";}
if (! -d $mirrorroot) { print header; print "No Mirror root found! at $mirrorroot";}
my $construct = "$mirrorroot/$section/$efile";
copy($maconstruct, $construct) || die ("Cant write to bacup : $! ");


It doesn't see the folder on the drive mapped to y:, I have also tried using \\servername and \\IPaddress in the path but it still can't see it.
Any tips on this given it is NT ?? Or do I have to make a specific connection (socket?) to this target machine and then try my test and copy statements??

I have tried this and also tried using a 'system("copy...
but both ways to copy return the same error ('no such file or dircetory'). I know it is there but I can't seem to see it.


Any NT-centric ideas?

Thanks

Jez
 
Hello,

Can someone please answer Jez. I have a similar problem. I too want to copy files from one server to another in the network (different domains however). The servers are all within a windows environment.

I'm starting small: trying to copy from my PC to a server in the network. It works when I use a drive map but not when I use the server name and share (which I would prefer to use).

So this works:
copy ("filename.txt","q:/someFolder/anotherFolder/filename.txt");

But this does not work:
copy("filename.txt","//serverName/hiddenShare$/folder/subfolder/filename.txt");

Anyone's help would be greatly appreciated!

JC
 
Yeah, sorry i never did resolve this, I used an NT batch file instead... passing the 2 argumaents to it from my script.
 
Hi Jez,

We found a solution to our problem which may or may not apply to your problem. And you're not gonna believe how simple it was!

Remember when I wrote:

But this does not work:
copy("filename.txt","//serverName/hiddenShare$/folder/subfolder/filename.txt");

All we had to do was this:

copy("filename.txt","\\\\serverName\\hiddenShare\$\\folder\\subfolder\\filename.txt");

We had to escape the "\\" hence "\\\\" and subsequent "\" becomes "\\" and the "$" becomes "\$". We had tried the escape sequence but we forgot to escape the darn "$"!

Hope this helps you too.

JC
 
Great, thanks...yes that does solve the problem i was having although I will only be able to use this in the future as i am working on a different contract now.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top