sush has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I am getting a file descriptor error when I am trying to map a network drive on Windows.
The network drive actually turns out to be mapped when I access it from Windows explorer, but I cannot access it through perl (to zip some files on the remote drive) .
The code and error message are displayed below.

Thanks for your help,
my $netObj = Win32::OLE->new('WScript.Network');

print join ("\n","\$source_drive => $source_drive ", "\$mapPath => $mapPath \n");

$netObj->MapNetworkDrive($source_drive,$mapPath,$boolPersistent,$user,$pass);
if ($!){
print " There was some error on mapping : $! \n";
}

--OUTPUT------

$source_drive => R:
$mapPath => \\11.16.152.96\G$
There was some error on mapping : Bad file descriptor
--update: I tried printing out $^E but it was empty, no OS specific error msg , but thanks for the tip BrowserUk.

Replies are listed 'Best First'.
Re: Win32::OLE Map Network Drive Error
by BrowserUk (Patriarch) on Oct 30, 2007 at 05:51 UTC
Re: Win32::OLE Map Network Drive Error
by Gangabass (Vicar) on Oct 30, 2007 at 09:41 UTC

    How about

    system('net use R: \\\\11.16.152.96\\G$');
    ?

    Note: not tested!

      Sorry about that guys,
      I learnt something today, $! may be set somewhere else between Step 1 and Step 3 and if you check it only after step 3 , you break your head thinking its set in Step 3.

      Sorry for the trouble.

      Thank you