Skip to content

Instantly share code, notes, and snippets.

@vls29
Created December 26, 2017 17:14
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 vls29/aac9d3efaf265734dfc1b64c46482160 to your computer and use it in GitHub Desktop.
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
#!/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
@vls29
Copy link
Author

vls29 commented Dec 26, 2017

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.

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