Last active
August 29, 2015 14:08
-
-
Save fredrike/245b8cc17fba767f410e to your computer and use it in GitHub Desktop.
Upload script for emoncms.org with data from openenergy monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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..