Skip to content

Instantly share code, notes, and snippets.

@jensihnow
Created February 9, 2014 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensihnow/8905218 to your computer and use it in GitHub Desktop.
Save jensihnow/8905218 to your computer and use it in GitHub Desktop.
TaHoma logger - simple getEvents caller
#!/bin/bash
# while loop for permanent processing
while :
do
# TaHoma LogIn
echo `curl -s -k -A "TaHoma/1.7.1 CFNetwork/548.0.4 Darwin/11.0.0" -b ./cookie.txt -c ./cookie.txt --data "userId=<USERID>&userPassword=<PASSWORD>" https://iphone-v17.overkiz.com/enduser-mobile-web/externalAPI/login`
while :
do
# define timestamp and starttime
STARTTIME=`date +%s`
TIMESTAMP=`date +"%Y-%m-%d %T"`
# TaHoma Getting Data
RESPONSE=`curl -s -k -A "TaHoma/1.7.1 CFNetwork/548.0.4 Darwin/11.0.0" -b ./cookie.txt -c ./cookie.txt https://iphone-v17.overkiz.com/enduser-mobile-web/externalAPI/getEvents`
echo -e "$TIMESTAMP $RESPONSE"
# Check if response with error or not
searchString="errorResponse"
if `echo ${RESPONSE} | grep "${searchString}" 1>/dev/null 2>&1`
then
break
fi
# Calculate runtime for sleep period
ENDTIME=`date +%s`
TIMEDELTA=`expr $ENDTIME - $STARTTIME`
TIME2WAIT=`expr 10 - $TIMEDELTA`
# waiting for next minute
sleep $TIME2WAIT
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment