1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/usr/local/bin/perl -w
use blib;
use strict;
use AFS::BOS;
my ($server, $cellname, $bos, $what, $ok);
die "Usage: $0 server [cell] all | bak | old | core\n" if $#ARGV < 0;
my $nargs = $#ARGV;
$server = shift;
$cellname = shift if $nargs == 2;
$what = shift if $nargs > 0;
$what = '' unless $what;
if ($cellname) { $bos = AFS::BOS->new($server, 0, 0, $cellname); }
else { $bos = AFS::BOS->new($server); }
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);
if ($what eq 'all') {
# warn "prune all \n";
$ok = $bos->prune(1); # delete ALL (.BAK, .OLD, CORE) files
}
elsif ($what eq 'bak') {
# warn "prune bak \n";
$ok = $bos->prune(0, 1); # delete .BAK files
}
elsif ($what eq 'old') {
# warn "prune old \n";
$ok = $bos->prune(0, 0, 1); # delete .OLD files
}
elsif ($what eq 'core') {
# warn "prune core \n";
$ok = $bos->prune(0, 0, 0, 1); # delete CORE files
}
else {
# warn "prune nothing \n";
$ok = $bos->prune; # nothing specified ... give error message
}
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);
#print "Status: $ok \n";
$bos->DESTROY;
|