#!/usr/bin/perl
+sub is_lock {
+ if ( -e "$ENV{'HOME'}/.antifraude/lock/antifraude.pid" ) {
+ # Lock file encontrado
+ return 1;
+ }
+ # No hay lock file!
+ return 0;
+}
+
+sub unlock {
+ unlink ("$ENV{'HOME'}/.antifraude/lock/antifraude.pid");
+}
+
+sub lock {
+ if (!is_lock()) {
+ local $lfile = "$ENV{'HOME'}/.antifraude/lock/antifraude.pid";
+ open(LOCKFILE,">>$lfile");
+ print LOCKFILE $$;
+ close(LOCKFILE);
+ return 1;
+ }
+ return 0;
+}
+
# Comparador de fecha para los archivos de llamada
sub byDate {
($year1,$mon1,$day1,$hr1,$min1) = $a =~ /([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/;
}
sub checkUmbrales {
- local(*callfields) = @_[0];
- my $callsfile = @_[1];
+ local(*callfields) = $_[0];
+ my $callsfile = $_[1];
+ print("Callfields: @callfields\n");
+ print("Callfile: $callsfile\n");
my $matchedUmbral = 0;
my $i = 0;
print("No se ha ingresado un directorio fuente de llamadas\n");
exit 1;
}
+
+# File locking..
+if (is_lock()) { exit 1; }
+lock();
+
# Defino some GLOBALS
$CONFDIR = shift;
$CONFDATA{logdir} = getConfVar("$CONFDIR/afinstal.conf",12);
logEntry("Fin proceso de: $filename",1);
}
+
+# Unlocking
+unlock();