I'm trying to write a script which tests the http response from various Node servers I have running and which then emails me if any respond with a 502 error from Nginx (meaning one or more server has crashed).
My approach is to write a shell-script and have it run as a cron job, and I'm using ssmtp to send the message through Gmail. Here is a snippet:
messageTemplate=`cat /home/sites/mailmsg.txt` ... email="$messageTemplate One or more sites is down!" mailCommand=`mail -s firstname.lastname@example.org < $email`
I'm able to get the contents of the ssmtp mailer template (To:, From:, etc.) with no issues. And I'm sure the email line concatenates just fine. The problem is that the mailCommand line fails with the line:
line 31: $email: ambiguous redirect
What is the proper way to pipe what is essentially that messageTemplate + a custom message into the first command (in this case,