Bash 명령을 찾을 수 없음 오류

Bash 명령을 찾을 수 없음 오류

다음 스크립트에서 다음 오류가 발생하는 이유는 무엇입니까?

./check1.sh: line 10: Hi,: command not found  
./check1.sh: line 21: syntax error: unexpected end of file

1.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" [email protected] <<EOS
`echo -e $mailbody`
EOS
fi
echo "email subject ::$subj"
echo "email body ::$mailbody"

답변1

라인 할당 mailbody오류입니다. 셸 명령줄 $body의 내용을 및/또는 $body1셸 명령줄로 호출 하고 있습니다 .

바꾸다

mailbody=$([ "$applicationstatus" == 200 ] && $body || $body1)

그리고

[ "$applicationstatus" = 200 ] && mailbody="$body" || mailbody="$body1"

관련 정보