Subversion Repositories computer_asset_manager_v1

Rev

Rev 9 | Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9 Rev 10
Line 54... Line 54...
54
      } # if
54
      } # if
55
   } # foreach
55
   } # foreach
56
   return $configuration;
56
   return $configuration;
57
} # sub loadConfig
57
} # sub loadConfig
58
 
58
 
59
sub sendReport {
-
 
60
   my ($parameters,$report) = @_;
-
 
61
   my %CLIParams ;
-
 
62
   $CLIParams{'-f'}  = qq/$$parameters{'mailFrom'}/    if $$parameters{'mailFrom'};
-
 
63
   $CLIParams{'-t'}  = qq/$$parameters{'mailTo'}/      if $$parameters{'mailTo'};
-
 
64
   $CLIParams{'-u'}  = qq/$$parameters{'mailSubject'}/ if $$parameters{'mailSubject'};
-
 
65
   $CLIParams{'-s'}  = qq/$$parameters{'mailServer'}/  if $$parameters{'mailServer'};
-
 
66
   $CLIParams{'-xu'} = qq/$$parameters{'smtpUser'}/    if $$parameters{'smtpUser'};
-
 
67
   $CLIParams{'-xp'} = qq/$$parameters{'smtpPass'}/    if $$parameters{'smtpPass'};
-
 
68
   $CLIParams{'-cc'} = qq/$$parameters{'mailCC'}/      if $$parameters{'mailCC'};
-
 
69
   $CLIParams{'-bcc'}= qq/$$parameters{'mailBCC'}/     if $$parameters{'mailBCC'};
-
 
70
   $CLIParams{'-l'}  = qq/$$parameters{'logFile'}/     if $$parameters{'logFile'};
-
 
71
   $CLIParams{'-a'}  = qq/$$parameters{'attachment'}/  if $$parameters{'attachment'};
-
 
72
   $CLIParams{'-o tls='} = qq/$$parameters{'tls'}/     if $$parameters{'tls'};
-
 
73
   
-
 
74
   $commandLine = qq/$$parameters{'emailScript'}/;
-
 
75
   die "Could not find executable $commandLine in sendEmailScript\n" unless -x $commandLine;
-
 
76
   $commandLine .= ' -q'; # make it act quietly
-
 
77
   foreach my $key ( keys %CLIParams ) {
-
 
78
      # depending on whether the key ends in an = or not, we will or will not use a space
-
 
79
      # between the key and the parameter
-
 
80
      $commandLine .= $key =~ m/=$/ ? " $key'$CLIParams{$key}'" : " $key '$CLIParams{$key}'";
-
 
81
   }
-
 
82
   $commandLine .= ' ' . $$parameters{'otherCLParams'} if $$parameters{'otherCLParams'};
-
 
83
   open SENDMAIL, "|$commandLine" or die "Could not open [$commandLine]: $!\n";
-
 
84
   print SENDMAIL $report;
-
 
85
   close SENDMAIL;
-
 
86
} # sendReport
-
 
87
 
-
 
88
# assumes parse_sysinfo.php returns one of the following codes
59
# assumes parse_sysinfo.php returns one of the following codes
89
# 0 - Processed Normally
60
# 0 - Processed Normally
90
# 1 - could not process file (not xml, yaml or ini)
61
# 1 - could not process file (not xml, yaml or ini)
91
# 2 - Invalid report, does not have one or more of report date, client name or computer name
62
# 2 - Invalid report, does not have one or more of report date, client name or computer name
92
# 3 - Invalid Report, invalid machine name
63
# 3 - Invalid Report, invalid machine name
Line 189... Line 160...
189
 
160
 
190
open SEND, "|$reportScript" or die "Could not find sendReport.pl: $!\n";
161
open SEND, "|$reportScript" or die "Could not find sendReport.pl: $!\n";
191
print SEND $emailString;
162
print SEND $emailString;
192
close SEND;
163
close SEND;
193
 
164
 
194
# &sendReport( $$config{'sendReport'}, $emailString );
-
 
195
 
-
 
196
1;
165
1;