Trying to figure out how to search through files on several Windows machines. If I leave out the 'find()' line, the program completes fine, mapping and unmapping the c$ share with no issues (success messages print to the terminal).
However, with the 'find()' line included, the files from the first machine will list correctly, but the rest of the machines do not, nor do I get successful messages regarding mapping the drives. What gives?

I realize that this could likely be done faster by trying to parallelize the searches to run on multiple machines at once or by getting the job to run on the remote computer, but without using Scheduled Tasks, I am not sure how to do that.

#!/perl/bin/perl use warnings; use strict; use File::Find; foreach my $computer (<>) { chomp($computer); print($computer, "\n"); system("net", "use", "z:", '\\\\' . $computer . '\\' . 'c$'); find(\&wanted, ('z:')); system("net", "use", "z:", "/DELETE"); } sub wanted { if ((-f $File::Find::name) && ($File::Find::name =~ m/log$/i)) { print($File::Find::name); if (open(FILE, $File::Find::name)) { print("\topened\n"); close(FILE); } else { warn("Cannot open $File::Find::name: $!\n"); print("\tfailed\n"); } } }

In reply to Problem with mapping windows shares and File::Find by romandas

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.