Skip to main content
added 21 characters in body
Source Link
gen_Eric
  • 227.7k
  • 42
  • 304
  • 343
COMPARE_RESULT=sudo php /home/xxx/compareMD5.php

This will not do what you think. You need to enclose the command in backticks so that it runs and COMPARE_RESULT will be set to its output.

COMPARE_RESULT=`sudo php /home/xxx/compareMD5.php`

When you compare strings, you need to use ==. = is for assigning values (like you've done above).

if [ "$COMPARE_RESULT" == "ok" ]; then
    echo error log is not changed
    EXITCODE=10
elif [ "$COMPARE_RESULT" == "mysqlerror" ]; then
    echo mysqlerror
    EXITCODE=11
elif [ "$COMPARE_RESULT" == "apacheerror" ]; then
    echo apacheerror
    EXITCODE=12
fi
COMPARE_RESULT=sudo php /home/xxx/compareMD5.php

This will not do what you think. You need to enclose the command in backticks so that it runs and COMPARE_RESULT will be set to its output.

COMPARE_RESULT=`sudo php /home/xxx/compareMD5.php`

When you compare strings, you need to use ==. = is for assigning values (like you've done above).

if [ "$COMPARE_RESULT" == "ok" ]; then
    echo error log is not changed
    EXITCODE=10
elif [ "$COMPARE_RESULT" == "mysqlerror" ]; then
    echo mysqlerror
    EXITCODE=11
elif [ "$COMPARE_RESULT" == "apacheerror" ]; then
    echo apacheerror
    EXITCODE=12
fi
COMPARE_RESULT=sudo php /home/xxx/compareMD5.php

This will not do what you think. You need to enclose the command in backticks so that it runs and COMPARE_RESULT will be set to its output.

COMPARE_RESULT=`sudo php /home/xxx/compareMD5.php`
Source Link
gen_Eric
  • 227.7k
  • 42
  • 304
  • 343

COMPARE_RESULT=sudo php /home/xxx/compareMD5.php

This will not do what you think. You need to enclose the command in backticks so that it runs and COMPARE_RESULT will be set to its output.

COMPARE_RESULT=`sudo php /home/xxx/compareMD5.php`

When you compare strings, you need to use ==. = is for assigning values (like you've done above).

if [ "$COMPARE_RESULT" == "ok" ]; then
    echo error log is not changed
    EXITCODE=10
elif [ "$COMPARE_RESULT" == "mysqlerror" ]; then
    echo mysqlerror
    EXITCODE=11
elif [ "$COMPARE_RESULT" == "apacheerror" ]; then
    echo apacheerror
    EXITCODE=12
fi