Hello James,

Tuesday, August 28, 2001, Kipp, James <[EMAIL PROTECTED]> wrote:

KJ> I have this script that recursed through a directory on a network drive and
KJ> it's subdirs flagging files based on a couple of params.

KJ> Firstly, I know this will be resource intensive. Is there a better way to do
KJ> this that is maybe not even a Perl solution?

KJ> Secondly, the script is failing to recurse! It just goes a couple of levels
KJ> and stops!! It changes to the top-level dir ok and opens it ok but that is
KJ> it.
KJ> I know about file find but I do not want to use it.

KJ> I am running NT Workstation, the mapped network drive is on a Novell Server.
KJ> Thanks for any help on this.
KJ> Here is the script:
KJ> ------------
KJ> # script will recurse through specified directory logging files that have
KJ> # not been modified in 60 days and are over 50MB.

KJ> # use strict;
KJ> use Cwd;
KJ> use File::Spec;
        
KJ> # system ('h:') or die "can't get to h:\n";
KJ> $log = 'c:\\temp\\chk_space.txt';
KJ> $path = 'dbm\\marketing_database_II';

open(LOG, ">>$log") or die "Can't open $log: $!";
KJ> print LOG "These files are over 60 days old and over 50MB\n\n";

KJ> &ScanDir($path);

ScanDir($path);

KJ> sub ScanDir
KJ> {
KJ>         my ($workdir) = shift;
KJ>         my ($start) = File::Spec->curdir();
your $start='.' here.
my ($start) = cwd;

KJ>         my @stuff;
KJ>         # my ($age, $size); 
KJ>         system(h:); #this fails to for some reason, so I have to manually do
#system(h:); #this fails to for some reason, so I have to manually do
chdir does that for you.

KJ>         chdir($workdir) or die "Can't cd to $workdir: $!\n";
KJ>         opendir(DIR, ".") or die "Can't open directory $path: $!\n";
KJ>         @stuff = grep (!/^\.\.?$/ , readdir(DIR));
KJ>         closedir(DIR);
                                
KJ>         foreach my $file (@stuff) {
KJ>                 # next if $file =~ /^\.\.?$/;
KJ>                 next if $file =~ /mediaCreate/;
KJ>                 if (-d $file)   {
KJ>                         &ScanDir($file);
                            ScanDir($file);
KJ>                         next;
KJ>                 }
                
                
KJ>                 if(((-M $file) > 60) && ((-s $file) > 1024 ** 2 * 50 )) {
KJ>                         print LOG "$workdir/$file\n";
KJ>                 }
KJ>                 chdir($start) or die "Unable to CD to $start: $!\n";
you don not want this here. it's algorythmical error.
#chdir($start) or die "Unable to CD to $start: $!\n";
KJ>         }
chdir($start) or die "Unable to CD to $start: $!\n";
KJ> }

        
KJ> close LOG;      


Best wishes,
 Maxim                            mailto:[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to