1

I referred to multiple articles to solve my problem but no luck. I'm trying curl inside if; as the value comparison is an arithmetic operation, I'm using the > operator with ((.

However, the command is failing with error

bash: ((: > 0: syntax error: operand expected (error token is "> 0")

Here is my command:

if (( $(curl --max-time 10 $serviceName) > 0)); then echo ERROR ; fi

What is wrong in the command?

2
  • 2
    What does the curl command actually output? Seems like it's not producing anything, which means the command reduces to if (( > 0 )); then. You need something for the left-hand operand to >. Commented Sep 18, 2018 at 14:16
  • 2
    If you are trying to check whether curl failed (rather than its output), then if ! curl ....; then echo ERROR: fi is what you want. Commented Sep 18, 2018 at 14:19

3 Answers 3

3

Thanks P.P

if ! curl --max-time 10 serviceName; then echo ERROR ; fi

worked for me!!

Sign up to request clarification or add additional context in comments.

Comments

1

I use this:

curl --max-time 10 "$someURL" || echo ERROR

Comments

0

This should work:

if (curl --maxtime 10 $servicename); then
   blah;
else
   echo "Error";
fi;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.