Gossamer Forum
Home : General : Perl Programming :

Experienced users help please

Quote Reply
Experienced users help please
Im on a RAQ4 and the vhosts are in directories like.....

site1
site2
site3
site4
site5
site6
site8

As you can see, site7 is missing. Now, I am using a stats script that reads the directories in the /home/sites/ directory and builds a stats page for each one. However it seems to think it is finished at site6 because site7 doesn't exist and so the stats pages for site8 upwards aren't built. Can someone tell me how to get around this.

Here is the relevant code:

#!/usr/bin/perl

$prefix = "/home/sites";

my $messages;

chdir "$prefix" or die "Can't cd to $prefix??: $!\n";
opendir THEROOT, $prefix or die "Couldn't open $prefix?: $!\n";
@allsites = grep !/^\.\.?$/, readdir THEROOT;

foreach $asite (@allsites)
{
if (-l "$asite")
{
$webpath = "$prefix/$asite/web";
$thepath = "$prefix/$asite/web/stats";

# Get the group id of the directory
my $gid = (stat $webpath)[5];
my $name = (getgrgid $gid)[0];

# Create a directory /web/stats if it isn't there yet
if (!-d $thepath)
{
mkdir $thepath, 775;
chown 0, $gid, $thepath;
chmod 0755, $thepath;
}


Any help is MUCH appreciated.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/