-
-
Save jsavage/736b835c6924b6054bfc46205a67a1b7 to your computer and use it in GitHub Desktop.
BtWiFi_with_FON automatic login written as a bash script. I have this running every 10 minutes on my raspberry pi
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 | |
# CONF | |
DBG=true | |
RELOG_UNAME=your@email.com | |
RELOG_PASSW=xxxxxxxxxxxxxxx | |
# END CONF | |
IS_LOGGED_IN=$(wget "https://www.btopenzone.com:8443/home" --timeout 30 -O - 2>/dev/null | grep "accountLogoff") | |
if [ "$IS_LOGGED_IN" ] | |
then | |
[[ $DBG ]] && echo "currently logged in. Nothing to do.." | |
else | |
[[ $DBG ]] && echo "It's not logged in.. Will log in!" | |
OUT=$(wget -qO- --post-data "USERNAME=$RELOG_UNAME&PASSWORD=$RELOG_PASSW" "https://btwifi.portal.fon.com/remote?res=hsp-login&HSPNAME=FonBT%3AGB&WISPURL=https%3A%2F%2Fwww.btopenzone.com%3A8443%2FfonLogon&WISPURLHOME=https%3A%2F%2Fwww.btopenzone.com%3A8443&VNPNAME=FonBT%3AGB&LOCATIONNAME=FonBT%3AGB") | |
ONLINE=$(echo $OUT | grep youre_online ) | |
if [ "$ONLINE" ] | |
then | |
[[ $DBG ]] && echo "You're online!" | |
else | |
[[ $DBG ]] && echo "Could not login :(" | |
fi | |
fi |
@jsavage I get the following error on your version:
sed: -e expression #1, char 15: invalid reference \1 on `s' command's RHS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
g0wfv commented on the original above https://gist.github.com/sscarduzio/05ed0b41d6234530d724
on Jun 21
Here's a subtly different version I wrote ...
#! /bin/bash
user=UsErNaMe
pass=PaSsWoRd
shopt -s extglob # enables pattern lists like +(...|...)
listOfESSID='+(BTFON|BTOpenzone|BTOpenzone-B|BTOpenzone-H|BTWi-fi|BTWifi|BTWiFI-with-FON|BTWifi-with-FON|_BTWi-fi)'
currentESSID=$(iwgetid | sed 's/."(.)".*/\1/g')
foo=$(wget "https://www.btopenzone.com:8443/home" --no-check-certificate --no-cache --timeout 30 -O - 2>/dev/null)
if [ $? -ne 0 ]
then
echo "Unable to reach btopenzone.com. Are you connected to the network?"
exit $?
fi
loggedIn=$(echo $foo | grep 'now logged on to BT Wi-fi')
if [ $? -eq 0 ]
then
echo "You're already logged in. Nowt to do!"
exit 0
else
echo -n "$currentESSID "
case "$currentESSID" in
$listOfESSID)
echo -n "is a valid Wifi network. Logging in ... "
foo=$(wget -qO - --no-check-certificate --no-cache --post-data "username=$user&password=$pass" "https://www.btopenzone.com:8443/tbbLogon")
loggedIn=$(echo $foo | grep 'now logged on to BT Wi-fi')
esac
fi