#!/usr/bin/perl use strict; use warnings; my $FILEPATH="/home/kami/info"; my $NOTIFY_FILE="$FILEPATH/notified"; my $cmd_list='calltest -l'; my $cmd_info='calltest -t "%s" -i'; my $cmd_pl1=q(/home/kami/scripts/checkfiles.pl -test="%s"); my $cmd_pl2=q(/home/kami/scripts/prowl.pl -application=test -event=test -notification="%s"); my %seen_files=(); my %notify_files=(); my %not_notify_files=(); $notify_files{$_}++ for(read_file($NOTIFY_FILE)); for my $line (qx($cmd_list)) { next if $line=~/^(?:Sum|ID)/; my ($id,$percent)=split(/\s+|:|,|;/,$line); # keine Ahnung wecher Separator das nun ist... my $name=''; $cmd=sprintf($cmd_info,$id); for my $info (qx($cmd)) { $name=$1 if($info=~/^ Name...(.+)/); } if(!$notify_files{$name} && $percent eq '100%' ) { # könntest du nun auch als Funktionen einbinden # das wäre schneller und sicherer # zudem ist dann die fehlersuche einfacher my $cmd1=splrintf($cmd_pl1,$name); system($cmd1)==0 or die("ERROR $cmd1\n"); my $cmd2=splrintf($cmd_pl2,$name); system($cmd2)==0 or die("ERROR $cmd2\n"); $notify_files{$name}++ } else { $not_notify_files{$name}++; } $seen_files{$name}++; } write_file($NOTIFY_FILE,sort keys(%notify_files)); ############################################################### sub read_file { my $file=shift; my @list=(); open(my $fh,'<',$file) or die ("ERROR open $file ($!)"); while(<$fh>) { chomp($_); push(@list,$_); } close($fh); return @list; } sub write_file { my $file=shift; my @list=@_; open(my $fh, '>', $file) or die("ERROR open $file ($!)"); print $fh "$_\n" for(@list); close($fh); }