![Bash 명령을 찾을 수 없음 오류](https://linux55.com/image/52645/Bash%20%EB%AA%85%EB%A0%B9%EC%9D%84%20%EC%B0%BE%EC%9D%84%20%EC%88%98%20%EC%97%86%EC%9D%8C%20%EC%98%A4%EB%A5%98.png)
다음 스크립트에서 다음 오류가 발생하는 이유는 무엇입니까?
./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"