[bcn-pm] Enviar email quan acaba un procés
Albert Vilella
avilella at gmail.com
Mon Jan 3 10:20:04 CST 2005
> > Ara em faltarà descobrir com controlar la finalització dels
> > processos i l'output que donen
>
> Això depèn en gran mesura de les eines d'IPC que vulguis emprar
> (pipes, semàfors, signals... man/perldoc perlipc). Sense més
> detalls del que fas o vols fer es fa difícil de proposar cap
> solució més ben definida.
>
Jo tinc feta bàsicament una cosa així, per a un mòdul Test.t:
--------------------------
[...]
my $command = "../variscan";
my $arg1;
my $arg2;
my $outfile = "/tmp/variscan.stdout";
my $errfile = "/tmp/variscan.stderr";
my $redirection = " 1>$outfile 2>$errfile";
my $commandstring = "";
if (-e $outfile) {unlink($outfile);}
if (-e $errfile) {unlink($errfile);}
$arg1 = "./data" . "/SARS.phy";
$arg2 = "./data" . "/SARS.conf";
$commandstring = "$command $arg1 $arg2 $redirection";
printf("# $commandstring\n");
run($commandstring);
[...]
#parse output
################################################################################
## FUNCTIONS
################################################################################
sub run {
my @args = @_;
my $sysstat = system(@args);
if ($sysstat == -1) {
print "failed to execute: $!\n";
}
elsif ($sysstat & 127) {
printf "child died with signal %d, %s coredump\n",
($sysstat & 127), ($sysstat & 128) ? 'with' : 'without';
}
else {
# successfull run
# printf "child exited with value %d\n", $sysstat >> 8;
}
}
1;
--------------------------
Suposo que a "sub run" deu fer comprovacions suficients sobre l'estat
del programa, però no sé si prou. Aquí es nota que no sóc enginyer
informàtic xDDD
Albert.
More information about the Barcelona-pm
mailing list