I am trying to write a perl script that emails whatever I give it in the first argument, but I need the email body to have multiple lines. When I pass text to the script (Using MIME::Lite, fyi), the email body only has a single line because the "\n" I pass in the script do not seem to be converted to newline in the email body.
Here is an example
Script Brief Content:
my $message = $ARGV;
sendEmail.pl "Issue: CPU usage is high \n Time: 11:20AM \n"
Issue: CPU issue
Issue: CPU issue \n Time: 12:00AM \n
This doesn't look like an issue with
perl, it's a problem with the
bash command that you typed. When you enter the following string literal in
"Issue: CPU usage is high \n Time: 11:20AM \n"
bash does not interpret the
\n character sequences as line breaks. You need a different syntax for that. You can use either of the following:
# bash sendEmail.pl $'Issue: CPU usage is high\nTime: 11:20AM\n'
# bash or sh sendEmail.pl 'Issue: CPU usage is high Time: 11:20AM '