1 |
#! /xdata/ccflib/perl5/perlbrew/perls/perl-5.18.4/bin/perl -w |
#! /usr/bin/env perl |
2 |
|
#! /xdata/ccflib/perl5/perlbrew/perls/perl-5.18.4/bin/perl |
3 |
# |
# |
4 |
# $Id: deleteccf,v 1.5 2014/12/02 14:06:51 ccflib Exp $ |
# $Id: deleteccf,v 1.7 2020/07/04 11:59:30 ccflib Exp $ |
5 |
# |
# |
6 |
# This script simply deletes all CCFs put in the subdir ccfdev/deleted. |
# Script to be run from crontab to delete any CCFs in |
7 |
# It is intended to be run by a crontab, either on xvsoc01 or in sasbld01 |
# /home/ccflib/ftp-area/private/ccfdevel/deleted |
8 |
|
|
9 |
require 5; |
require 5; |
10 |
use strict; |
use strict; |
11 |
|
use warnings; |
12 |
use vars '%ENV'; |
use vars '%ENV'; |
|
use lib "$ENV{'HOME'}/cgi"; |
|
|
$ENV{'PATH'} .= "$ENV{'HOME'}/bin:"; |
|
13 |
|
|
14 |
# Can not use Ccflib.pm located in $HOME/cgi because it has definitions for directories only on xvsoc01. |
# If DEBUG is set, warns without executing |
|
# use Ccflib; |
|
15 |
|
|
16 |
my $host=qx/\/bin\/hostname | cut -d. -f1/ ; |
my $debug = ""; |
17 |
my $homedir="/home/ccflib" ; |
if ( $ENV{'DEBUG'} ) { |
18 |
|
$debug = "$ENV{'DEBUG'}"; |
19 |
|
} |
20 |
|
|
21 |
|
|
22 |
|
my $host=qx/\/bin\/hostname/ ; |
23 |
chomp($host); |
chomp($host); |
|
$homedir="/data/xmm/ccflib" if ( $host eq "xvsoc01" ) ; |
|
24 |
|
|
25 |
chdir "$homedir/ftp-area/private/ccfdevel/deleted/" ; |
chdir "/home/ccflib/ccf_ftp/private/ccfdevel/deleted/"; |
26 |
|
|
27 |
|
|
28 |
my $deletes; |
my $deletes; |
29 |
foreach my $ccf (glob("*.CCF")){ |
foreach my $ccf (glob("*.CCF")){ |
30 |
qx/rm -f $ccf/; |
if ($debug) { |
31 |
if(! $? >> 8){ |
print "$ccf is marked for deletion\n"; |
32 |
warn("Deletion of $ccf failed\n"); |
} else { |
33 |
} else { |
print "Going to delete $ccf\n"; |
34 |
$deletes .= "$ccf "; |
unlink $ccf; |
35 |
} |
if(! $? >> 8){ |
36 |
|
warn("Deletion of $ccf failed\n"); |
37 |
|
} else { |
38 |
|
$deletes .= "$ccf "; |
39 |
|
} |
40 |
|
} |
41 |
} |
} |
42 |
if($deletes){ |
if(! $debug && $deletes){ |
43 |
print "The following constituents were found in the removed subdirectory:\n"; |
print "Script deleteccf running on $host\n"; |
44 |
print "$deletes\n"; |
print "Removed CCFs:\n"; |
45 |
print "Now they have been definetely erased.\n"; |
print " $deletes\n"; |
46 |
} |
} |
|
|
|
|
##my $x = qx/ccfnotify -t development -d $deletes/; |
|
|
## |
|
|
##if(! $? >> 8){ |
|
|
## warn("Notification failed\n"); |
|
|
##} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|