S
solaristar
(I think I may have posted this msg in the wrong group before, so my
apologies for a double post, i believe this is the right place)
==
First please forgive me if this is the wrong way to go about asking
this question.
I have a script im working on that is looking to only get the
filenames with ".mw.|.cw.|.uw." and exclude any filenames (which
happen to be FQDNs of servers) that do not have that criteria
the structure to search is /data*/backups/$server/daily.0/$server
(where $server would have the .mw.|.cw.|.uw. characteristic)
this is what I have thus far, I dont feel this is the fastest way to
go about doing this (im not sure), I also want to make sure to exclude
and not even "parse" any dirs that dont have the afore mentioned
criteria,
any feedback is appreciated
====
#!/usr/bin/perl
use strict;
use warnings;
use File::Find::Rule;
use File::Basename qw/basename dirname/;
my @data_dir =
qw { /data/backups }; # list here the data dir if you want to
loop on it.
foreach my $dir (@data_dir) {
print "looking at $dir..\n";
my ( $bkpcount, $dbcount ) = 0; # db and backup file counter
# Gather server name with .mw, .cw, .uw on fqdn
my %server_w_log;
# This part will search for every directory with .mw, .uw. cw and
take the base name as key to hash
opendir( DIR, $dir ) or warn "can't open $dir\n";
my @servers = readdir(DIR);
foreach my $server (@servers) {
next if $server =~ m/^\./;
%server_w_log =
map { my $tempfile = basename $_; $tempfile => $_ }
File::Find::Rule->directory->name(qr/.*\.(mw|uw|cw).*/)
->in("$dir/$server/daily.0");
print "server is $server..\n";
}
close(DIR);
...etc...
(there's more to the script but this is the first part that's giving
me problems.
any help is greatly appreciated.
apologies for a double post, i believe this is the right place)
==
First please forgive me if this is the wrong way to go about asking
this question.
I have a script im working on that is looking to only get the
filenames with ".mw.|.cw.|.uw." and exclude any filenames (which
happen to be FQDNs of servers) that do not have that criteria
the structure to search is /data*/backups/$server/daily.0/$server
(where $server would have the .mw.|.cw.|.uw. characteristic)
this is what I have thus far, I dont feel this is the fastest way to
go about doing this (im not sure), I also want to make sure to exclude
and not even "parse" any dirs that dont have the afore mentioned
criteria,
any feedback is appreciated
====
#!/usr/bin/perl
use strict;
use warnings;
use File::Find::Rule;
use File::Basename qw/basename dirname/;
my @data_dir =
qw { /data/backups }; # list here the data dir if you want to
loop on it.
foreach my $dir (@data_dir) {
print "looking at $dir..\n";
my ( $bkpcount, $dbcount ) = 0; # db and backup file counter
# Gather server name with .mw, .cw, .uw on fqdn
my %server_w_log;
# This part will search for every directory with .mw, .uw. cw and
take the base name as key to hash
opendir( DIR, $dir ) or warn "can't open $dir\n";
my @servers = readdir(DIR);
foreach my $server (@servers) {
next if $server =~ m/^\./;
%server_w_log =
map { my $tempfile = basename $_; $tempfile => $_ }
File::Find::Rule->directory->name(qr/.*\.(mw|uw|cw).*/)
->in("$dir/$server/daily.0");
print "server is $server..\n";
}
close(DIR);
...etc...
(there's more to the script but this is the first part that's giving
me problems.
any help is greatly appreciated.