# Finds all of the thingtolookfor.txt across all servers and prints out a list # of those people that do not have them to log.txt use strict; use Benchmark; my $t0 = new Benchmark; my ($server,$usershare); my $out='//mymachine/myshare/log.txt'; my @servers=('XXY','ZZZ','ETC'); open OUT,">$out"; foreach $server (@servers){ my $dir1="//$server/c\$/chompy"; # Check if chompy share is on $C or D$ if (!(-e "$dir1")){#if directory doesn't exist try d$ $dir1="//$server/d\$/chompy"; if (!(-e "$dir1")){ die "Directory not does not exist on $server\n...Exiting Script.\n"; } } # Read the user shares opendir(DIR, $dir1) or die "can't opendir $dir1: $!"; #weed out dots and get only dirs my @dirs = grep { !/^\./ && -d "$dir1/$_" } readdir(DIR); closedir DIR; foreach $usershare(@dirs){ my $userdir="$dir1/$usershare"; if (!-e "$userdir/thingtolookfor.txt"){ print OUT "$userdir:\tno\n"; print "$userdir:\tno\n"; } } } close OUT; #benchmarking info my $t1 = new Benchmark; my $td = timediff($t1, $t0); print OUT "The code took:",timestr($td),"\n";