Skip to content

Instantly share code, notes, and snippets.

@ntfc
Created February 14, 2017 18:06
Show Gist options
  • Save ntfc/cd37a3b822183b1741f132247197a1eb to your computer and use it in GitHub Desktop.
Save ntfc/cd37a3b822183b1741f132247197a1eb to your computer and use it in GitHub Desktop.
Auto re-connect to Nova Arcada's Free Wi-fi
#!/usr/bin/env bash
# TODO: wait for no Internet connection to run this script
set -x
while true
do
ABC=$(curl -L -I www.abola.pt | grep '^Location' | awk '{print $2}' | grep -o 'loginurl=.*$' | cut -d'=' -f2)
export ABC="$ABC"
DEF=$(python2 -c 'import urllib2; import os; print urllib2.unquote(os.environ["ABC"])')
sleep 1
DEF=${DEF%$'\r'}
GHI=$(curl "$DEF" | sed ':a;N;$!ba;s/\n//g' | grep -Po '(?<=<a id="button" href=")[^"]*')
sleep 1
JKL=$(curl -I "$GHI" | grep -o 'url=.*' | cut -d'=' -f2-)
sleep 1
JKL=${JKL%$'\r'}
curl "$JKL"
sleep 10m
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment