...
Code Block | ||
---|---|---|
|
||
#!/bin/bash #replace the api_key API_KEY="aa1bf85f3d7f43d9abd104df9ea16b4e" #replace the thing_id THING_ID="0f769aa7a50411e39dda53645593b491" #replace the property_id PROPERTY_ID="1d1c41aaa50411e39dda53645593b491" URL="http://devapi.gadgetkeeper.com" TMP_FILE="/tmp/tmp.txt" curl -i -X GET -H "X-ApiKey: $API_KEY" "$URL/v1/things/$THING_ID/properties/$PROPERTY_ID/value.json" > "$TMP_FILE" 2> /dev/null if [ -f "$TMP_FILE" ]; then IS_OK=`cat "$TMP_FILE" | head -1 | grep "200 OK"` #echo $IS_OK #cat "$TMP_FILE" | head -1 if [ "$IS_OK" != "" ]; then RESULT=`cat "$TMP_FILE" | tail -1` echo Value: $RESULT else echo "Error" cat "$TMP_FILE" | head -1 fi #rm -f "$TMP_FILE" else echo "Error" fi |
...