--- bin/deleteccf 2003/10/31 15:52:32 1.3 +++ bin/deleteccf 2021/07/27 13:09:16 1.8 @@ -1,42 +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: deleteccf,v 1.2 2002/03/19 15:05:09 ccflib Exp $ +# $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 warnings; use vars '%ENV'; -use lib "$ENV{'HOME'}/cgi"; -$ENV{'PATH'} .= "$ENV{'HOME'}/bin:"; -use Ccflib; -#chdir $Ccflib::develrm or die("Cannot access $Ccflib::develrm\n"); -chdir "/home/ccflib/ftp-area/private/ccfdevel/deleted/" or die("Cannot access /home/ccflib/ftp-area/private/ccfdevel/deleted/\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 "; - } -} -if($deletes){ - print "The following constituents were found in the removed subdirectory:\n"; - print "$deletes\n"; - print "Now they have been definetely erased.\n"; +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"; +}