我有下一个脚本,当尝试比较变量值时,如果等于" NO"或" SI" (西班牙语是的)由于某些原因它不能正常工作我一直在通过else(SI)继续工作,尽管变量中的实际值是" NO"。它甚至被印在电子邮件主题中。
我担心我可能会成为一些我无法看到的隐形角色,但它会在那里?
这是脚本:
#!/usr/bin/ksh
VAR=$(/home/userName/scripts/loadedresource.ksh | egrep 'SI|NO')
MAIL_FILE="testfile.txt"
rm -f $MAIL_FILE
echo "From:Script" > $MAIL_FILE
echo "To:Me<me@company.com>" >> $MAIL_FILE
echo "Subject:RESOURCE LOADED-> $VAR" >> $MAIL_FILE
echo "Content-Type: text/html" >> $MAIL_FILE
echo "<html>" >> $MAIL_FILE
echo "<body style='font-family:calibri;font-size:14px;'>" >> $MAIL_FILE
if [ "$VAR" == "NO" ]
then
echo "<h2> Resource not loaded, please open ticket </h2>" >> $MAIL_FILE
else
echo "<h2> Resource loaded successfully </h2>" >> $MAIL_FILE
fi
mail me@company.com < $MAIL_FILE