Leser: 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#!/usr/bin/perl -w use strict; use warnings; use Getopt::Long; use File::Copy; use File::Spec; use File::Glob ':glob'; use Archive::Rar; my ($source_path, $test_check, $verzeichnis, $dest_path,$file); my %options = (); GetOptions(\%options, 'test=s'); my $testdir='/home/kami/test'; my $test2dir='/home/kami/test2'; $verzeichnis=File::Spec->join($downloaddir, $options{'test'}); $test_check=File::Spec->join($testdir, '*.test'); if(bsd_glob($test_check)) { for $source_path (bsd_glob($test_check)) { if(-f $source_path) { (undef,undef,$file) = File::Spec->splitpath( $source_path ); $dest_path= $test_check=bsd_glob(File::Spec->join($test2dir, $file)); my $file2 = "/home/kami/scripts/test.txt"; open FILE3, ">$file2" or die "unable to open $file $!"; warn "oeffne jetzt die datei $file2"; print FILE3 $source_path."\n"; print FILE3 $dest_path."\n"; close(FILE3); move($source_path,$dest_path) or die("ERROR move($source_path,$dest_path) $!\n"); } } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
FILEPATH="/home/kami/info"
CONFIG_FILE="$FILEPATH/config"
NOTIFY_FILE="$FILEPATH/notified"
ALL_FILE="/tmp/test.all"
TMP_FILE="/tmp/test.tmp"
LOCK_FILE="/tmp/test"
#calltest liefert daten.
# main
calltest -l | gawk '{
if ($1 != "Sum:" && $1 != "ID") {
print $1,$2
}
}' | while read id percent
do
reply="`calltest -t "$id" -i | grep -E '^ Name|^ test'`"
#echo $reply
name="`echo "$reply" | grep '^ Name' | cut -c 9-`"
# check that notification is not yet sent
grep -q "$hash" "$NOTIFY_FILE"
if [ $? = 1 -a "$percent" = "100%" ]
then
/home/kami/scripts/checkfiles.pl "-test=$name"
/home/kami/scripts/prowl.pl -application=test -event=test "-notification=$name"
echo "$hash" >> "$NOTIFY_FILE"
fi
echo "$hash" >> "$ALL_FILE"
done
# remove deleted torrents from sent notifications list
sort "$NOTIFY_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$NOTIFY_FILE"
sort "$ALL_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$ALL_FILE"
comm -1 -2 "$NOTIFY_FILE" "$ALL_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$NOTIFY_FILE"
exitAndClean 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use File::Copy; use File::Spec; use File::Glob ':glob'; my $test=''; my $testdir='/home/kami/test'; my $test2dir='/home/kami/test2'; my $infofile='/home/kami/scripts/test.txt'; GetOptions( 'test=s' => \$test, 'source_dir=s'=> \$testdir, 'dest_dir=s' => \$test2dir, 'info_file=s' => \$infofile, ) or die("unbekannte Option!"); my $verzeichnis=File::Spec->join($downloaddir, $test); my $test_check=File::Spec->join($testdir, '*.test'); for $source_path (bsd_glob($test_check)) { if(-f $source_path) { my (undef,undef,$file) = File::Spec->splitpath( $source_path ); my $dest_path=File::Spec->join($test2dir, $file); warn "oeffne jetzt die datei $file2"; open(my $fh, '>>' $infofile) or die "unable to open $infofile $!"; print $fh $source_path." ==> ".$dest_path."\n"; close($fh); move($source_path,$dest_path) or die("ERROR move($source_path,$dest_path) $!\n"); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#!/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); }