--- bin/deleteccf 2002/03/18 18:28:57 1.1 +++ bin/deleteccf 2021/07/27 13:09:16 1.8 @@ -1,31 +1,46 @@ -#! /usr/local/bin/perl -w +#! /usr/bin/env perl +#! /xdata/ccflib/perl5/perlbrew/perls/perl-5.18.4/bin/perl # -# Giuseppe Vacanti (cosine science & computing bv) -# -# $Id$ +# $Id: deleteccf,v 1.7 2020/07/04 11:59:30 ccflib Exp $ # +# Script to be run from crontab to delete any CCFs in +# /home/ccflib/ftp-area/private/ccfdevel/deleted + require 5; use strict; -use lib "/data/xmm/ccflib/cgi"; -$Env{'PATH'} .= "/data/xmm/ccflib/bin:"; -use Ccflib; +use warnings; +use vars '%ENV'; -chdir $Ccflib::develrm or die("Cannot access $Ccflib::develrm\n"); +# If DEBUG is set, warns without executing -my $deletes; -foreach my $ccf (glob("*.CCF")){ - qx/rm -f $ccf/; - if(! $? >> 8){ - warn("Deletion of $ccf failed\n"); - } else { - $deletes .= "$ccf "; - } +my $debug = ""; +if ( $ENV{'DEBUG'} ) { + $debug = "$ENV{'DEBUG'}"; } -my $x = qx/ccfnotify -t development -d $deletes/; -if(! $? >> 8){ - warn("Notification failed\n"); -} +my $host=qx/\/bin\/hostname/ ; +chomp($host); +chdir "/home/ccflib/ccf_ftp/private/ccfdevel/deleted/"; + +my $deletes; +foreach my $ccf (glob("*.CCF")){ + if ($debug) { + print "$ccf is marked for deletion\n"; + } else { + print "Going to delete $ccf\n"; + unlink $ccf; + if(! $? >> 8){ + warn("Deletion of $ccf failed\n"); + } else { + $deletes .= "$ccf "; + } + } +} +if(! $debug && $deletes){ + print "Script deleteccf running on $host\n"; + print "Removed CCFs:\n"; + print " $deletes\n"; +}