Created
June 8, 2017 13:45
-
-
Save taiko19xx/fbdd4cb854ebad0ed9d7df3274cf1cd7 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
WAIT=10 | |
NEXT=0 | |
SESSION=`curl -s https://~/start | jq -r .session_id` | |
LAST=0 | |
gpspipe -w | jq --unbuffered -c '. | if .class == "TPV" then {lat,lon,time} else empty end' | while read -r f; do | |
CURRENT=`date +%s` | |
TARGET=$(( LAST + WAIT )) | |
if [ $CURRENT -ge $TARGET ]; then | |
JSON=`echo $f | jq --arg SESSION $SESSION '.+{"session_id": $SESSION}'` | |
curl -s "Accept: application/json" -H "Content-type: application/json" -X POST -d "$JSON" https://~/post | |
LAST="$CURRENT" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment