0

Update I made this:

curl -s "http://192.168.11.93:436/getmovieplayinfo?" | grep -Po '(?<=,"total_time":)(.*?)(?=})'

and this gave me number 5757, what will be code after this to check "if > 500 then" ?


Old question:

I need help to create bash script and run script if number from curl response is > 500.

I want script looks like this:

if curl "http://192.168.11.93:436/getmovieplayinfo?" and if total_time is > 500
then
    echo "run run run"                   
fi

This is response from curl:

{"success":true,"msg":"","playinfo":{"bd_file_path":"","file_path":"BDMV","e_play_status":0,"e_play_mode":0,"cur_time":5,"total_time":5757}}

Thank you for help.

jasko887
  • 29
  • 4
  • This is not valid bash. Is it pseudo code ? Could you post a real attempt ? – Aserre Nov 02 '22 at 17:08
  • Welcome to Stack Overflow. Please read [ask]. You don't have to write "_update_" or "_old question_" in your question. Please [edit] it and formulate **one** clear question. The history can be seen in the revision history if necessary, it should not be part of the post itself. And make sure your question contains a [mre] instead of separate "snippets", so that we understand what you are trying to do. Be as specific as possible in order to get a correct and useful answer. – wovano Nov 04 '22 at 09:09

1 Answers1

1

You can use the jq utility, it is helpful for handling JSON data :

if curl "http://192.168.11.93:436/getmovieplayinfo?" | jq -e '.playinfo.total_time > 500 | not'; then
    echo "run run run";
fi
Aaron
  • 24,009
  • 2
  • 33
  • 57