Skip to content

Instantly share code, notes, and snippets.

@whywaita
Last active November 3, 2017 19:05
Show Gist options
  • Save whywaita/70bddc5d58f06fceb3b9182dcfb71f80 to your computer and use it in GitHub Desktop.
Save whywaita/70bddc5d58f06fceb3b9182dcfb71f80 to your computer and use it in GitHub Desktop.
#!/bin/bash
FILE=$1
client_key="your-client-key"
device_id="your-device-id"
DATA="[$(cat ${FILE} | grep "integer" | sed '$d' | cut -d">" -f2 | cut -d"<" -f1 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/,/g')]"
FREQ="$(cat ${FILE} | grep -A 1 "freq" | grep "integer" | cut -d">" -f2 | cut -d"<" -f1)"
JSON="{\"format\":\"raw\",\"freq\":${FREQ},\"data\":${DATA}}"
BODY="clientkey=${client_key}&deviceid=${device_id}&message=${JSON}"
echo ${BODY}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment