I have a simple script that tries to curl and URL and echo a string if it failed or succeeded. But I get the following warnings, depending on how I form this if statement.
Depending on the quotes I use in the statement below I get the following warnings:
: -ne: unary operator expected
: integer expression expected
With the alternative check (as comment), I get the following error
((: != 0 : syntax error: operand expected (error token is "!= 0 ")
The script:
c=`curl -s -m 10 https://example.com` || ce=$?
#if (( ${je} != 0 )); then
if [ ${ce} -ne 0 ]; then
echo "Failed"
else
echo "Succeeded"
fi
How do I correctly check the return value of the curl command in a bash if-statement?