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 = $ARGV1;


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

In reply to Mapping a remote network folder.... by biswanath_c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.