I have the following subroutine:
sub email_warning { my $threshhold_value = $ARGV[0]; my $current_load_avg = &run_sar(); my $email_body = "15 minute load average of $current_load_avg has +equaled or exceeded the threshhold you specified: $threshhold_value"; open (MAIL, "|mailx -s \"15 minute load average warning\" wentwort +h\@localhost"); # print $email_body; print MAIL $email_body; close MAIL; }
The email body I receive contains only the part of $email_body up to and including the $current_load_avg variable. e.g. "15 minute load average of 4.01" and nothing after that. I'm guessing it has to do with mailx, because if I print the $email_body scalar, it looks fine. I'm perplexed.
UPDATE: OK, this is resolved. Toolic was right, printing $current_load_avg as a test printed it on a line by itself.
As it happens, that troublesome newline character was the only thing making the email send successful. When I chomped it, all the generated emails had null message bodies. I had to add a "\n" to the
print MAIL $email_body;statement.
Thanks everyone for the help.| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |