Hi,
I was trying to write a PERL code that would map to a remote network folder and pull osme files from there to the local machine.
This is the code snippet:
----------------------------------------------------
use Win32::OLE;
use File::Copy;
$strDrive = $ARGV[0];
# e.g. N:
$strPath = $ARGV
1;
unless (-d $strPath )
{
print "Folder $source does not exist! \n";
die;
}
$boolPersistent = 0;
# True = Persistent ; False = Not Persistent
# ------ END CONFIGURATION ---------
$WshNetwork = Win32::OLE->new('WScript.Network');
eval
{
$WshNetwork->MapNetworkDrive($strDrive, $strPath, $boolPersistent, '', '') or print "Map network drive failed! original error: $! \n";
};
----------------------------------------------------
Now, I have a couple of questions:
1) The code worked just fine when i tried to test it on my machine; but the code should actually be deployed on our server - when i tried running it on our server (from where it would map to a remote server folder), the code just won't work!
I know that this is probably not a PERL question, maybe a Windows Server question, but owuld be good if someone can throw some light as to what might be wrong!
2) This line:
$WshNetwork->MapNetworkDrive($strDrive, $strPath, $boolPersistent, '', '')
a) I tried googling, but could not get much info!
Does this API return anything? The return value seems to be empty even in the case of a successful map!
b) How can i catch an exception if this API fails?
c) This API returns " Bad file descriptor" error even if the API maps to the remote folder successfully!! What would this error mean then?!
Thanks and regards
Biswanath