Created
December 26, 2017 17:14
-
-
Save vls29/aac9d3efaf265734dfc1b64c46482160 to your computer and use it in GitHub Desktop.
Emails the position of your ranking on blitzortung.org every time it changes
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 | |
email=$1 | |
epc=$(date +%s) | |
echo $epc | |
# Country does not seem to be important | |
res=$(curl --data "info_time=$epc&info_email=$email&info_country=United+Kingdom&info_text=TSqrb" http://en.blitzortung.org/cover_your_area.php) | |
#echo "-----------------------------" | |
#echo "HTML Response" | |
#echo $res | |
#echo "-----------------------------" | |
html=$(echo "$res" | grep $email) | |
#echo "-----------------------------" | |
#echo "Position Text" | |
#echo $html | |
#echo "-----------------------------" | |
textpositionstart=411+${#email}+1 | |
echo "textpositionstart: $textpositionstart" | |
position=${html:$textpositionstart:6} | |
position=$(echo $position | sed 's@^[^0-9]*\([0-9]\+\).*@\1@') | |
echo "position: $position" | |
lastpositionfilename=blitzortung-last-position.txt | |
lastposition=$(cat $lastpositionfilename) | |
catresult=$? | |
echo "catresult $catresult" | |
if [ "$catresult" -eq "1" ]; then | |
echo "didn't find last position file" | |
lastposition=100000 | |
else | |
echo "found last position file" | |
fi | |
echo "lastposition: $lastposition" | |
if [ "$position" -lt "$lastposition" ]; then | |
echo $position | mail -s "blitzortung.org position" $email | |
echo $position > $lastpositionfilename | |
else | |
echo "position not less than $lastposition: $position" | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires mailutils - or replace the mail section with your favourite package as required.
Give the script executable permission and then you can call the script like
./blitzortung-position.sh [REPLACE WITH EMAIL USED TO SIGN UP ON BLITZORTUNG.ORG]
I have the script hardcoded with my email address and the script on a daily cron to send me any changes in position.