Subversion Repositories computer_asset_manager_v1

Rev

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

Rev 33 Rev 74
Line 115... Line 115...
115
   open SENDMAIL, "|$commandLine" or die "Could not open [$commandLine]: $!\n";
115
   open SENDMAIL, "|$commandLine" or die "Could not open [$commandLine]: $!\n";
116
   print SENDMAIL $report;
116
   print SENDMAIL $report;
117
   close SENDMAIL;
117
   close SENDMAIL;
118
} # sendReport
118
} # sendReport
119
 
119
 
-
 
120
sub sendViaSendmail {
-
 
121
   my ( $parameters, $report ) = @_;
-
 
122
   my @header;
-
 
123
   push @header, 'To: ' . qq/$$parameters{'mailTo'}/;
-
 
124
   push @header, 'From: ' . qq/$$parameters{'mailFrom'}/;
-
 
125
   push @header, 'Subject: ' . qq/$$parameters{'mailSubject'}/;
-
 
126
   $report = join( "\n", @header ) . "\n\n" . $report . "\n.\n";
-
 
127
   open SENDMAIL, "|sendmail $$parameters{mailTo}" or die "could not open sendmail: $!\n";
-
 
128
   print SENDMAIL $report;
-
 
129
   close SENDMAIL;
-
 
130
} 
-
 
131
  
-
 
132
 
120
########################################################################
133
########################################################################
121
# Main Program
134
# Main Program
122
########################################################################
135
########################################################################
123
 
136
 
124
# Read anything passed on STDIN to prepend to e-mail
137
# Read anything passed on STDIN to prepend to e-mail
Line 147... Line 160...
147
      $message .= sprintf( "%6d\t%s\n", $device, $results->{$device}->{name} );
160
      $message .= sprintf( "%6d\t%s\n", $device, $results->{$device}->{name} );
148
   }
161
   }
149
   $message .= '='x40 . "\n\n";
162
   $message .= '='x40 . "\n\n";
150
}
163
}
151
 
164
 
-
 
165
 
152
$results = $dbh->selectall_hashref( $query, 'ID' );
166
$results = $dbh->selectall_hashref( $query, 'ID' );
153
foreach my $id ( keys %$results ) {
167
foreach my $id ( keys %$results ) {
154
   $message .= $results->{$id}->{Date} . "\t" . $results->{$id}->{Client} . "\t" . $results->{$id}->{Device} . "\n";
168
   $message .= $results->{$id}->{Date} . "\t" . $results->{$id}->{Client} . "\t" . $results->{$id}->{Device} . "\n";
155
   $message .= $results->{$id}->{Notes} . "\n\n";
169
   $message .= $results->{$id}->{Notes} . "\n\n";
156
}
170
}
157
$dbh->disconnect();
171
$dbh->disconnect();
158
 
172
 
159
#print $message;
173
#print $message;
-
 
174
if ( $$configuration{'sendReport'}{'emailScript'} ) {
160
&sendReport( $$configuration{'sendReport'}, $message );
175
   &sendReport( $$configuration{'sendReport'}, $message );
-
 
176
} else {
-
 
177
   &sendViaSendmail( $$configuration{'sendReport'}, $message );
-
 
178
}
161
 
179
 
162
1;
180
1;
-
 
181
                  
163
 
182