Line 3... |
Line 3... |
3 |
use IO::Interactive qw(is_interactive interactive busy);
|
3 |
use IO::Interactive qw(is_interactive interactive busy);
|
4 |
use YAML::XS;
|
4 |
use YAML::XS;
|
5 |
use Cwd 'abs_path';
|
5 |
use Cwd 'abs_path';
|
6 |
#use Data::Dumper;
|
6 |
#use Data::Dumper;
|
7 |
|
7 |
|
- |
|
8 |
use File::Basename;
|
- |
|
9 |
|
- |
|
10 |
my $MY_DIRECTORY = abs_path(dirname(__FILE__) );
|
- |
|
11 |
|
8 |
my $CRON= ! is_interactive(); # determine if we are in interactive shell
|
12 |
my $CRON= ! is_interactive(); # determine if we are in interactive shell
|
9 |
|
13 |
|
10 |
# control the flow of the program. $CHECKMAIL is pretty clear.
|
14 |
# control the flow of the program. $CHECKMAIL is pretty clear.
|
11 |
# if $PROCESS is false and $MOVEFILES is true, the files will be moved
|
15 |
# if $PROCESS is false and $MOVEFILES is true, the files will be moved
|
12 |
# but not processed (ie, they were processed some other way)
|
16 |
# but not processed (ie, they were processed some other way)
|
13 |
my $CHECKMAIL=1; #controls whether we will check the mail or not
|
17 |
my $CHECKMAIL=1; #controls whether we will check the mail or not
|
14 |
my $PROCESS=1; # controls whether we will process the files
|
18 |
my $PROCESS=1; # controls whether we will process the files
|
15 |
my $MOVEFILES=1; # controls whether we will move the files successfully processed
|
19 |
my $MOVEFILES=1; # controls whether we will move the files successfully processed
|
16 |
|
20 |
|
17 |
my $MY_DIRECTORY; # will hold the directory of the script
|
- |
|
18 |
my $DATADIR; # will hold the reports directory
|
21 |
my $DATADIR; # will hold the reports directory
|
19 |
my $UNPROCESSED; # will hold the location for unprocessed reports
|
22 |
my $UNPROCESSED; # will hold the location for unprocessed reports
|
20 |
my $MAXTOPROCESS = 10000;
|
23 |
my $MAXTOPROCESS = 10000;
|
21 |
my %filesProcessed;
|
24 |
my %filesProcessed;
|
22 |
|
25 |
|
23 |
# following are used to find the configuration file
|
26 |
# following are used to find the configuration file
|
24 |
my $confFileName = "sysinfoRead.conf.yaml";
|
27 |
my $confFileName = "sysinfoRead.conf.yaml";
|
25 |
my @searchPaths = ( '/etc/camp', '/opt/camp', '/opt/camp/sysinfo', getcwd() );
|
28 |
my @searchPaths = ( '/etc/camp', '/opt/camp', '/opt/camp/sysinfo', $MY_DIRECTORY );
|
26 |
|
29 |
|
27 |
|
30 |
|
28 |
sub loadConfig {
|
31 |
sub loadConfig {
|
29 |
my ( $confFileName, @searchPaths ) = @_;
|
32 |
my ( $confFileName, @searchPaths ) = @_;
|
30 |
my $configuration;
|
33 |
my $configuration;
|
Line 34... |
Line 37... |
34 |
$filename = $searchPaths[$i] . '/' . $confFileName;
|
37 |
$filename = $searchPaths[$i] . '/' . $confFileName;
|
35 |
if ( -e $filename ) {
|
38 |
if ( -e $filename ) {
|
36 |
#print "Found $filename\n";
|
39 |
#print "Found $filename\n";
|
37 |
open CONF, "<$filename" or warn "Could not read $filename: $!\n";
|
40 |
open CONF, "<$filename" or warn "Could not read $filename: $!\n";
|
38 |
$configuration = Load( join( '', <CONF> ) );
|
41 |
$configuration = Load( join( '', <CONF> ) );
|
- |
|
42 |
close CONF;
|
39 |
last; # exit out of the loop; we don't try to load it more than once
|
43 |
last; # exit out of the loop; we don't try to load it more than once
|
40 |
} # if
|
44 |
} # if
|
41 |
} # foreach
|
45 |
} # foreach
|
42 |
return $configuration;
|
46 |
return $configuration;
|
43 |
} # sub loadConfig
|
47 |
} # sub loadConfig
|
Line 96... |
Line 100... |
96 |
}
|
100 |
}
|
97 |
|
101 |
|
98 |
# get our configuration set up first
|
102 |
# get our configuration set up first
|
99 |
|
103 |
|
100 |
my $config = &loadConfig( $confFileName, @searchPaths );
|
104 |
my $config = &loadConfig( $confFileName, @searchPaths );
|
101 |
die "Could not find configuration file $confFileName\n" unless $config;
|
105 |
die "Could not find configuration file $confFileName in " . join( ', ', @searchPaths) . "\n" unless $config;
|
- |
|
106 |
|
- |
|
107 |
# just some convenience variables
|
102 |
$DATADIR = $$config{'datapath'};
|
108 |
$DATADIR = $$config{'datapath'};
|
103 |
$UNPROCESSED=$DATADIR . '/' . $$config{'unprocessed_path'};
|
109 |
$UNPROCESSED=$DATADIR . '/' . $$config{'unprocessed_path'};
|
104 |
|
110 |
|
105 |
use File::Basename;
|
- |
|
106 |
$MY_DIRECTORY = abs_path(dirname(__FILE__) );
|
111 |
# check that the executables exist before continuing
|
107 |
$getMailScript = "$MY_DIRECTORY/" . $$config{'getMailScript'};
|
112 |
$getMailScript = "$MY_DIRECTORY/" . $$config{'getMailScript'};
|
108 |
$processMailScript = "$MY_DIRECTORY/" . $$config{'processMailScript'};
|
113 |
$processMailScript = "$MY_DIRECTORY/" . $$config{'processMailScript'};
|
109 |
die "Could not find the getMailScript [$getMailScript] in $MY_DIRECTORY\n" unless -e $getMailScript;
|
114 |
die "Could not find the getMailScript [$getMailScript] in $MY_DIRECTORY\n" unless -e $getMailScript;
|
110 |
die "Could not find the processMailScript [$processMailScript] in $MY_DIRECTORY\n" unless -e $processMailScript;
|
115 |
die "Could not find the processMailScript [$processMailScript] in $MY_DIRECTORY\n" unless -e $processMailScript;
|
111 |
|
116 |
|