Hi,
Newbie question...
This script delete logs on remote machine mapped to drive "z:", based on
"disk is above %x of capacity.
use strict;
use warnings;
use Win32::AdminMisc;
my $drive="z:";
my ($Total, $Free) = Win32::AdminMisc::GetDriveSpace ( $drive );
my @Out = `dir $drive`;
(my $StandardFree) = ( $Out[$#Out] =~ /\s+([\d,]+)\s+byte(s)? free/i );
$StandardFree =~ s/,//g;
my $ratio =$Free/$Total*100;
print "z: has $ratio\% of free space \n";
if ($ratio<5) {
# print "disk is full \n";
my $oldest = sprintf "%s", (sort{ (-M $b) <=> (-M$a) } glob("z:\\*"));
unlink $oldest || die "Can't unlink($oldest): $!";
print "$oldest\n";
}
In this code the output is one file which is unlink. I would like to
alter this code in the part of the "if" loop (at the bottom), & replace
it with "while", so it will unlink files as much as needed to get below
% ratio number. How do I do it?
thanx
Ronen Kfir
System Administrator
CIT div.
Tel Aviv University
Tel: 972-3-6407416
Fax: 972-3-6405158
cellular: 972-55-405910
E-mail: [EMAIL PROTECTED]