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");
}
}
}