Skip to content

Instantly share code, notes, and snippets.

@fredrike
Last active August 29, 2015 14:08
Show Gist options
  • Save fredrike/245b8cc17fba767f410e to your computer and use it in GitHub Desktop.
Save fredrike/245b8cc17fba767f410e to your computer and use it in GitHub Desktop.
Upload script for emoncms.org with data from openenergy monitor
#!/bin/sh
APIKEY="YOUR KEY"
trap '' 1 2 9 15 SIGSTOP
stty -F /dev/usb/acm/0 9600 -hupcl
while true; do
if [ -r /dev/usb/acm/0 ]; then
while read F; do
[ -z "$F" ] && continue
# wget -O /dev/null "http://emoncms.org/input/post.json?apikey=${APIKEY}&json=${F}" &> /dev/null &
/opt/bin/wget -nv -t 4 -T 5 -O- -o /var/log/emoncms.log "http://emoncms.org/input/post.json?apikey=${APIKEY}&json=${F}" &> /dev/null &
done < /dev/usb/acm/0
else
sleep 5
fi
done
@fredrike
Copy link
Author

fredrike commented Nov 3, 2014

wget can be replaced by:

echo -e "GET /input/post.json?apikey=${APIKEY}&json=${F} HTTP/1.1\nHost: emoncms.org\n\n" | nc emoncms.org 80 &> /dev/null &

I'm not sure, but it might be faster..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment