Thread Perl Verzeichnisse durchsuchen (27 answers)
Opened by Jens at 2011-06-03 11:14

Gast Jens
 2011-06-03 11:14
#149386 #149386
hallo zusammen,

Ich habe hier ein skript, welches ich mit meinem halbwissen zusammen gebaut habe, jetzt hänge ich seit einer stunde an einem simplen problem.

Code: (dl )
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
#!/usr/bin/perl 
#Einbinden nötiger Module
use strict;
use warnings;
use English;
use Getopt::Long;
use File::stat;
use vars qw($PROGNAME);
use lib "/usr/lib64/nagios/plugins";
my $pfad = shift ;
local *DIR;
my @dateien = ();
my $pfadtotal = '';
my $groesse = 0;
my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V);
my ($result, $message, $age, $size, $st);

# Verzeichnis lesen
opendir(DIR, $pfad);
@dateien = readdir(DIR);
closedir(DIR);

# Addition oder Rekursion fuer alle gelesenen
foreach my $datei (@dateien) {
next if ($datei eq '.' || $datei eq '..');
print "DATEI: $pfad\n";

$pfadtotal = "$pfad/$datei";
$opt_w = 240000000;
$opt_c = 6000000000;
$opt_W = 0;
$opt_C = 0;
$opt_f = "";

if(-d $pfadtotal) {
$st = File::stat::stat($pfadtotal);
$age = time - $st->mtime;
$size = $st->size;

$result = 'OK';

#if (($opt_c and $age > $opt_c)) {
$result = 'CRITICAL';
#}
#elsif (($opt_w and $age > $opt_w)) {
$result = 'WARNING';
#}

print "FILE_AGE $result: $pfadtotal is $age seconds old \n";
print "VERZEICHNIS: $pfadtotal\n";
} else {
print "NNNEEEEIIINNN"
}
}


Use of uninitialized value in opendir at ./verzeichnisalter.perl line 20.

Ich weiß nicht warum das nicht initialiesiert sein soll :(

Bitte hilfe wenn möglich,

gruß Jens
Last edited: 2011-06-03 11:23:33 +0200 (CEST)

View full thread Perl Verzeichnisse durchsuchen