Line 266... |
Line 266... |
266 |
#
|
266 |
#
|
267 |
#######################################################
|
267 |
#######################################################
|
268 |
sub sendResults {
|
268 |
sub sendResults {
|
269 |
my ( $globals, $transports, $message, $scriptDirectory ) = @_;
|
269 |
my ( $globals, $transports, $message, $scriptDirectory ) = @_;
|
270 |
# die Dumper( $transports );
|
270 |
# die Dumper( $transports );
|
271 |
foreach my $key ( @$transports ) {
|
271 |
foreach my $key ( sort { $a <=> $b } %$transports ) {
|
272 |
if ( $key->{'sendScript'} ) {
|
272 |
if ( $transports->{$key}->{'sendScript'} ) {
|
273 |
print "Trying to find file " . $key->{'sendScript'} . " in " . join( "\n\t", @{$scriptDirectory} ) . "\n" if $TESTING > 2;;
|
273 |
print "Trying to find file " . $transports->{$key}->{'sendScript'} . " in " . join( "\n\t", @{$scriptDirectory} ) . "\n" if $TESTING > 2;;
|
274 |
my $sendScript = &findFile( $key->{'sendScript'}, $scriptDirectory );
|
274 |
my $sendScript = &findFile( $transports->{$key}->{'sendScript'}, $scriptDirectory );
|
275 |
if ( $sendScript ) {
|
275 |
if ( $sendScript ) {
|
276 |
# load the chosen script into memory
|
276 |
# load the chosen script into memory
|
277 |
require $sendScript;
|
277 |
require $sendScript;
|
278 |
# merge the globals in
|
278 |
# merge the globals in
|
279 |
while ( my ( $gkey, $value ) = each %$globals ) {
|
279 |
while ( my ( $gkey, $value ) = each %$globals ) {
|
280 |
$key->{$gkey} = $value;
|
280 |
$transports->{$key}->{$gkey} = $value;
|
281 |
}
|
281 |
}
|
282 |
# do variable substitution for any values which need it
|
282 |
# do variable substitution for any values which need it
|
283 |
foreach my $thisOne ( keys %{$key} ) {
|
283 |
foreach my $thisOne ( keys %{$transports->{$key}} ) {
|
284 |
print "$thisOne\n" if $TESTING > 3;
|
284 |
print "$thisOne\n" if $TESTING > 3;
|
285 |
if ( $key->{$thisOne} =~ m/(\$configuration\{'hostname'\})|(\$reportDate)|(\$configuration\{'clientName'\})|(\$configuration\{'serialNumber'\})/ ) {
|
285 |
if ( $transports->{$key}->{$thisOne} =~ m/(\$configuration\{'hostname'\})|(\$reportDate)|(\$configuration\{'clientName'\})|(\$configuration\{'serialNumber'\})/ ) {
|
286 |
$key->{$thisOne} = eval "\"$key->{$thisOne}\"";
|
286 |
$transports->{$key}->{$thisOne} = eval "\"$transports->{$key}->{$thisOne}\"";
|
287 |
}
|
287 |
}
|
288 |
}
|
288 |
}
|
289 |
|
289 |
|
290 |
#%$transports{$key}{keys %$globals} = values %$globals;
|
290 |
#%$transports{$key}{keys %$globals} = values %$globals;
|
291 |
#print Dumper( $$transports[$key] );
|
291 |
#print Dumper( $$transports[$key] );
|
292 |
#next;
|
292 |
#next;
|
293 |
# execute the "doit" sub from that script
|
293 |
# execute the "doit" sub from that script
|
294 |
if ( $TESTING > 3 ) {
|
294 |
if ( $TESTING > 3 ) {
|
295 |
print $message;
|
295 |
print $message;
|
296 |
} else {
|
296 |
} else {
|
297 |
my $return = &doit( $key, $message );
|
297 |
my $return = &doit( $transports->{$key}, $message );
|
298 |
return $return if ( $return == 1 );
|
298 |
return $return if ( $return == 1 );
|
299 |
}
|
299 |
}
|
300 |
} else {
|
300 |
} else {
|
301 |
print "Could not find " . $$transports[$key]{'sendScript'} . ", trying next transport\n";
|
301 |
print "Could not find " . $$transports[$key]{'sendScript'} . ", trying next transport\n";
|
302 |
} # if..else
|
302 |
} # if..else
|