Skip to content

Instantly share code, notes, and snippets.

@whee
Created November 23, 2012 01:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whee/2ec052638855b3a3d6c3 to your computer and use it in GitHub Desktop.
Save whee/2ec052638855b3a3d6c3 to your computer and use it in GitHub Desktop.
Twine to cosm shell script
#!/bin/sh
pounce_json=/place/to/store/json/for/a/twine
grace_json=/place/to/store/json/for/another/twine
curl -s -b 'user_id=[your twinedotsupermechanical cookie]' -k 'https://twine.supermechanical.com/rt/[your twine id]?cached=1' > ${pounce_json}
curl -s -b 'user_id=[your twinedotsupermechanical cookie]' -k 'https://twine.supermechanical.com/rt/[your other twine id]?cached=1' > ${grace_json}
pounce_temp=$(jshon -e values -e 1 -e 1 < ${pounce_json})
grace_temp=$(jshon -e values -e 1 -e 1 < ${grace_json})
curl --request PUT \
--data "{\"version\":\"1.0.0\",\"datastreams\":[{\"id\":\"grace_temperature\", \"current_value\":${grace_temp}}, {\"id\":\"pounce_temperature\", \"current_value\":${pounce_temp}}]}" \
--header "X-ApiKey: [your cosm api key]" \
http://api.cosm.com/v2/feeds/[your cosm feed number]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment