Hi ,
Iam using this command inside my perl script.
system("net use M: \\\\Stmroot\\data\\Essoc\\Legal&Comp\\LC_GMP\\reports\\bo");
...
script code
..
system("net use M: /DELETE ");
Iam getting Following error:
Network Drive is Already In use
Couldnot find network path
So iam able to Copy files from M drive. But Why iam not able to Disconnect it.
Any Syntax error:?
Perl
Last Comment
sunilbains
8/22/2022 - Mon
Adam314
You can't unmap the drive if anything is using anything on that drive. You can use the handle program to find out what is using that drive. It doesn't come with windows, but is a free download: http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
FishMonger
Are you doing anything in your script that creates a connection the M drive, such as opening a file or directory handle? If so, are you closing that connection prior to deleting the drive mapping?
sunilbains
ASKER
SO that means, we cannot map and unmap drive in the same Script?.
#!/usr/bin/perl
use File::Copy;
use strict;
system("net use M: \\\\Stmroot\\data\\Essoc\\Legal&Comp\\LC_GMP\\reports\\bo");
open(MYDATA, "D:/1.txt") or die("Error: cannot open file 'gdmp_pdf_file_list.out': $!\n");
my $line;
while( $line = <MYDATA> ){
chomp($line);
print "$line\n";
if ( -e "U:$line" )
{
copy ("U:$line","D:/x/y/z) or warn "Could not copy $line: $!\n";
}
else
{
print "File $line Does not Exist\n";
}
}
close MYDATA;
system("erase \\\\nldn1062pww\\compmonitor\\GDMP\\GSS\\Script\\gdmp_pdf_file_list.out");
system("net use M: /DELETE ");
I just need to close M after files are copied..
sunilbains
ASKER
Sorry M = U
Adam314
I don't see anything that should be causing a problem.
If you try to run the net use U: /DELETE after your script finishes, does it work?
Try sleeping for a few seconds before attempting to unmap the drive, in case windows does any caching.
...system("erase ...");sleep(10);system("net use U: /DELETE");
Hi Adam,
Got Following Err after putting 10 seconds
system error 85 has occurred.
The local device name is already in use.
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
Iam also not able to unmap from DOS.
Script is Running from Schduler
Adam314
You got all of that from the perl script, or from the command line?
sunilbains
ASKER
From Perl Script..
Also when i tried to unmap it from DOS , I got same error
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx