Why would the following script give following errors :
./check1.sh: line 10: Hi,: command not found
./check1.sh: line 21: syntax error: unexpected end of file
check1.sh:
#!/bin/bash
subj="host `hostname`"
healthcheckstatus=$(curl -s -o /dev/null -w '%{http_code}' http://localhost)
body="Hi, Application is up"
body1="Hi, Application is down"
mailbody=$([ "$applicationstatus" == 200 ] && $body || $body1)
if [ $healthcheckstatus != "200" ]
then
mail -s "$subj" me@domain.com <<EOS
`echo -e $mailbody`
EOS
fi
echo "email subject ::$subj"
echo "email body ::$mailbody"
mailbody
is wrong. You're calling the contents of$body
and/or$body1
as a shell command line.