I have a http cgi command (http://cameraIP:port/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=user&pwd=password) which returns in browser<CGI_Result>    <result>0</result>    <IOAlarm>0</IOAlarm>    <motionDetectAlarm>1</motionDetectAlarm>    <soundAlarm>0</soundAlarm>    <record>0</record>    <sdState>0</sdState>    <sdFreeSpace>0k</sdFreeSpace>    <sdTotalSpace>0k</sdTotalSpace>    <ntpState>1</ntpState>    <ddnsState>0</ddnsState>    <url>http%3A%2F%2Fgg3460.myfoscam.org%3A22222</url>    <upnpState>0</upnpState>    <isWifiConnected>0</isWifiConnected>    <wifiConnectedAP></wifiConnectedAP>    <infraLedState>1</infraLedState></CGI_Result>I want to create a script which will check if motionDetectAlarm equals to 2 and calls a restfull api put method. Is it possible?I can call the resfull api with curl -X PUT -d arg=val -d arg2=val2 localhost:8080How I can do the while loop? I want the loop running forever. Thanks.
script checking html
shell script;scripting
Loop forever, pulling the web page and looking for the exact HTML code. grep -q will exit with success if the specific tag and value are present, which will allow the trailing curl to run:while :do  wget or curl the CGIProxy script | grep -q '<motionDetectAlarm>2</motionDetectAlarm>' &&     curl -X PUT -d arg=val -d arg2=val2 localhost:8080done