Even simpler...

opendir DIR, "/logs/test";
@dirs = readdir DIR;
closedir DIR;
foreach (@dirs) {
         if ( -d "/$_") {
                 # do your stuff
                 # Notice that you need to preceed the $_ with the path you 
passed to opendir.
         }
}


R

At 16:47 30/09/2002 -0500, eric gregory wrote:
>Ok, I've got this script which I pulled off of a website for rotating 
>apache logfiles.  But since I'm runnig numberous sites on my server it 
>doesn't quite do what I need.
>
>It works just fine for a single set of logfiles for instance if the files 
>are in /logs/test in the example below.  but what I have is a number of 
>subdirectories under /logs/test like /logs/test/site1, /logs/test/site2, 
>/logs/test/site3
>
>I'd like the script to go to each directory under the test directory and 
>rotate the logs there, how do I do this.
>
>I thought it would entail changing the $LOGPATH= parameter to something 
>like /logs/test/* but no luck.
>
>I hope I've made that clear
>
>Any help is appreciated
>Eric
>Heres the script
>#######################
>#!/usr/bin/perl
>  $LOGPATH='/logs/test/';
> 
>@LOGNAMES=('access_log','error_log','referer_log','agent_log','access.log','error.log');
> 
>
>  $PIDFILE = '/var/run/httpd.pid';
>  $MAXCYCLE = 4;
>
>  chdir $LOGPATH;  # Change to the log directory
>  foreach $filename (@LOGNAMES) {
>     for (my $s=$MAXCYCLE; $s >= 0; $s-- ) {
>         $oldname = $s ? "$filename.$s" : $filename;
>         $newname = join(".",$filename,$s+1);
>         rename $oldname,$newname if -e $oldname;
>     }
>  }
>  kill 'HUP',`cat $PIDFILE`;
>####################


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

Reply via email to