Skip to content

Instantly share code, notes, and snippets.

@sscarduzio
Created August 24, 2014 21:20
Show Gist options
  • Save sscarduzio/05ed0b41d6234530d724 to your computer and use it in GitHub Desktop.
Save sscarduzio/05ed0b41d6234530d724 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
#!/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
@lalagreeze
Copy link

I released a software to automate BT-Wifi login process.

https://github.com/s4l1h/bt-wifi-auto-login

I'm pretty newbie and I don't understand how to run this or what will run this. there is a long list of releases and I'm not sure if it's for computers or a phone. Please help for a simpleton. I have been racking my brain for a few hours.

@aidanmacgregor
Copy link

aidanmacgregor commented May 31, 2022

I released a software to automate BT-Wifi login process.
https://github.com/s4l1h/bt-wifi-auto-login

I'm pretty newbie and I don't understand how to run this or what will run this. there is a long list of releases and I'm not sure if it's for computers or a phone. Please help for a simpleton. I have been racking my brain for a few hours.

This Solution Uses Shell Script, Bash Specifically Mainly Linux Environment

His solution uses the GO language, You would need to find a way to execute GO software on your system to run it,

what OS are you running and trying to keep online all the time?

@aidanmacgregor
Copy link

I released a software to automate BT-Wifi login process.
https://github.com/s4l1h/bt-wifi-auto-login

I'm pretty newbie and I don't understand how to run this or what will run this. there is a long list of releases and I'm not sure if it's for computers or a phone. Please help for a simpleton. I have been racking my brain for a few hours.

i have a shell script for open WRT & linux (tested using WSL2), Also a service for openWRT & i also made a Macrodroid Service (For Android Devices) to automate these logins that may be helpful, can see them here :) https://github.com/aidanmacgregor/BTWi-fi_Autologin-Shell_Script-MACRODROID-WISPr-HTTP_POST-HTTP_GET-OpenWRT

@lalagreeze
Copy link

Also

I released a software to automate BT-Wifi login process.
https://github.com/s4l1h/bt-wifi-auto-login

I'm pretty newbie and I don't understand how to run this or what will run this. there is a long list of releases and I'm not sure if it's for computers or a phone. Please help for a simpleton. I have been racking my brain for a few hours.

i have a shell script for open WRT & linux (tested using WSL2), Also a service for openWRT & i also made a Macrodroid Service (For Android Devices) to automate these logins that may be helpful, can see them here :) https://github.com/aidanmacgregor/BTWi-fi_Autologin-Shell_Script-MACRODROID-WISPr-HTTP_POST-HTTP_GET-OpenWRT

Thanks, I have used the Macrodriod (android connected to extender)and it works well. But the only issue is when I'm gaming online, I get around 3-5 second timeouts. which isn't much but when FPS gaming, it's a lot.

I wanted to try and get my computer to connect separately using @s4l1h script (connect through Ethernet with a separate extender). I installed GO (well I think I did properly). When I double click on "bt-wifi-auto-login-windows-amd64" my computer ask me what application to use. I Downloaded the source code and entered in my login info in the app.txt then tried running it in visual studio code and when I run the code it keeps saying "You are not logged on to BT". Really don't know what I am doing wrong.

Running it through marcodriod has been my best option, but it also seems to give me a bit more latency and small timeouts.

Windows 10 - just trying to have a smooth gaming time. upload speed 70Down and 20Up

@aidanmacgregor
Copy link

aidanmacgregor commented May 31, 2022

Also

I released a software to automate BT-Wifi login process.
https://github.com/s4l1h/bt-wifi-auto-login

I'm pretty newbie and I don't understand how to run this or what will run this. there is a long list of releases and I'm not sure if it's for computers or a phone. Please help for a simpleton. I have been racking my brain for a few hours.

i have a shell script for open WRT & linux (tested using WSL2), Also a service for openWRT & i also made a Macrodroid Service (For Android Devices) to automate these logins that may be helpful, can see them here :) https://github.com/aidanmacgregor/BTWi-fi_Autologin-Shell_Script-MACRODROID-WISPr-HTTP_POST-HTTP_GET-OpenWRT

Thanks, I have used the Macrodroid (android connected to extender)and it works well. But the only issue is when I'm gaming online, I get around 3-5 second timeouts. which isn't much but when FPS gaming, it's a lot.

I wanted to try and get my computer to connect separately using @s4l1h script (connect through Ethernet with a separate extender). I installed GO (well I think I did properly). When I double click on "bt-wifi-auto-login-windows-amd64" my computer ask me what application to use. I Downloaded the source code and entered in my login info in the app.txt then tried running it in visual studio code and when I run the code it keeps saying "You are not logged on to BT". Really don't know what I am doing wrong.

Running it through macrodroid has been my best option, but it also seems to give me a bit more latency and small timeouts.

Windows 10 - just trying to have a smooth gaming time. upload speed 70Down and 20Up

How often are these timeouts? unfortunately timeouts are always gong to happen when the service needs logged in again, this script i believe checks for the landing page and sees what text id in the webpage every 60 seconds, this is always going to take a second or 2 to download the page & grep it and another second or 2 to run the login url the methods,

Same with the go implementation it checks internet and has to run similar process & will also have small drops when login is needed

i use checks ping twice with a timeout 1 second each, either way it has to be signed out, the behaviour of BT Wifi is when logging off (manually testing) the internet will continue to work for about 10 second (ping test) before internet actually drops, relogging in in this time period still makes 2 or 3 seconds of packet drop as login is run, even if the login is re run within that 10 second window, it doesn't count and will still disconnect after the 10 second requiring re login anyway and that 2 or 3 seconds to detect the connectivity being down OR the landing page text, and run login URL, this rules out the idea i had of manually logging out every 3;59 and login in again quickly enough as would still get kicked by BT a min later at their 4 hour mark

i have optimised my solution for speed & to be online as much as possible, but some packet drop every 4 hours or so is unavoidable (BT Logout & Require re sign in every 4 hours) as either way a check needs to run & then a login URL needs to run also this means a maximum of a few seconds, fast enough online gaming donst error out (GTA Online Xbox One) with connection lost messages, his go implementation will have the same timing issues, a shell script would be easier to run and use for this also, i never bothered with trying the GO version Mainly because i wanted the router to login itself & i wanted to keep it simple & shell works with no additional software or dependencies, i see you are using windows, you could use WSL2 for the script but this also seems heavy no will make no difference i think (although i would love to know if you experiment and can get the timings better) :)

@lalagreeze
Copy link

Thank you so much for your reply. I finally got @s4l1h script to work. I guess his instructions were for someone with some knowledge of coding and running GO. I feel stupid as I didn't realise I had to take off the HASHTAGS for for it to work ↓↓↓↓

for bt broadband

#app_login_url=https://www.btwifi.com:8443/tbbLogon
#post_username=youremailaddress@hotmail.co.uk
#post_password=yourpassword
#post_xhtmlLogon=https://www.btwifi.com:8443/tbbLogon

I got it working now. I managed to change to timing from seconds to milliseconds, just to have more control. I will update you no how that goes.

Now my PC runs separately from my access point ( your microdriod Meth). hoping this will smooth out for my gaming now.

It's crazy to think that was been stuck on for a very long time and only needed a simple fix.

@aidanmacgregor
Copy link

aidanmacgregor commented May 31, 2022

Thank you so much for your reply. I finally got @s4l1h script to work. I guess his instructions were for someone with some knowledge of coding and running GO. I feel stupid as I didn't realise I had to take off the HASHTAGS for for it to work ↓↓↓↓

for bt broadband

#app_login_url=https://www.btwifi.com:8443/tbbLogon #post_username=youremailaddress@hotmail.co.uk #post_password=yourpassword #post_xhtmlLogon=https://www.btwifi.com:8443/tbbLogon

I got it working now. I managed to change to timing from seconds to milliseconds, just to have more control. I will update you no how that goes.

Now my PC runs separately from my access point ( your microdriod Meth). hoping this will smooth out for my gaming now.

It's crazy to think that was been stuck on for a very long time and only needed a simple fix.

awesome, glad your up and running, deffo let me know how your timings and stability goes, i've never used go but might try again with this login program for curiosity's sake, I'm also looking into "incorporate Bash commands into a Windows batch file or PowerShell script" to see if this can produce an easier windows login, Thats the idea in my head anyway haha, but i'm learning all this as i go :)

@lalagreeze
Copy link

A little update with @s4l1h script. I now have much lower ping and I disconnect a lot less (once every 4+ hours compared to 30min-1hour with macrodriod) , but when it tries to reconnect it can take a while sometimes (3-8seconds or sometimes 30 seconds). I think this could be on the btwifi router side, as when i refresh the web Brower btwifi doesnt come up. will update in a few weeks to come.

@aidanmacgregor
Copy link

aidanmacgregor commented Jun 12, 2022

A little update with @s4l1h script. I now have much lower ping and I disconnect a lot less (once every 4+ hours compared to 30min-1hour with macrodriod) , but when it tries to reconnect it can take a while sometimes (3-8seconds or sometimes 30 seconds). I think this could be on the btwifi router side, as when i refresh the web Brower btwifi doesnt come up. will update in a few weeks to come.

nice im currently learning and writing a windows .EXE program that runs in the system tray using vb.net for this also to experiment with, think its almost done, don't think i will use it much as i use the openwrt solution but i wanted to make a nice windows solution (other than running the bash script inside windows) and it was something useful for me to learn with :)
VB6 - 1

@SpikeTheLobster
Copy link

nice im currently learning and writing a windows .EXE program that runs in the system tray using vb.net for this also to experiment with, think its almost done, don't think i will use it much as i use the openwrt solution but i wanted to make a nice windows solution (other than running the bash script inside windows) and it was something useful for me to learn with :)

I would certainly be interested once it's ready - still using a .BAT run by the scheduler, which works fine but is obviously not incredibly reliable!

@aidanmacgregor
Copy link

aidanmacgregor commented Jun 13, 2022

nice im currently learning and writing a windows .EXE program that runs in the system tray using vb.net for this also to experiment with, think its almost done, don't think i will use it much as i use the openwrt solution but i wanted to make a nice windows solution (other than running the bash script inside windows) and it was something useful for me to learn with :)

I would certainly be interested once it's ready - still using a .BAT run by the scheduler, which works fine but is obviously not incredibly reliable!

Uploaded & Ready To Try :)

https://github.com/aidanmacgregor/BT_Wi-fi_Autologin_-_OpenWrt_Windows.EXE_Linux_Android-Macrodroid
Capture

@SpikeTheLobster
Copy link

Won't run on Win7, so I'm probably missing something from VBNet. Also would be nice to have a timer entry, so we can set our own delay. :)

@aidanmacgregor
Copy link

aidanmacgregor commented Jun 13, 2022

Needs at least .net 4.6, this is included & should run on all windows 10 & 11 automatically, i targeted .net 4.6 as its compatible as far back as windows vista after manually installing it on older OS :)

@SpikeTheLobster
Copy link

Needs at least .net 4.6, this is included & should run on all windows 10 & 11 automatically, i targeted .net 4.6 as its compatible as far back as windows vista after manually installing it on older OS :)

Well, that's odd... I ran the .NET 4.6 updater and apparently I already have 4.7.2. "Repaired" that but it still won't run. Says I need to check whether I need x32 or x64 (I assume it's an x64 exe). Gah!

@aidanmacgregor
Copy link

not entirely sure will try targeting 32 bit specifically, current timings are coded as follows,
IF NO INTERNET = ping (500ms timeout), wait (500ms), Ping (500ms Timeout), Run Selected Login
IF INTERNET Ping (Timeout Not Relevant), Wait (1000ms), Loop Back To Ping

@SpikeTheLobster
Copy link

not entirely sure will try targeting 32 bit specifically, current timings are coded as follows, IF NO INTERNET = ping (500ms timeout), wait (500ms), Ping (500ms Timeout), Run Selected Login IF INTERNET Ping (Timeout Not Relevant), Wait (1000ms), Loop Back To Ping

I don't think anyone still uses 32-bit, do they? Not sure why mine (x64) won't run it, to be honest, but then I haven't reformatted and reinstalled for years (used to do it every 6 months) so Windows has probably accumulated a whole load of icky stuff that gets in the way...
The timing thing: I meant between checks, sorry. I have my current batch going every 2 minutes or so, which can give a fair bit of downtime if the network's rubbish but avoids getting things piled up with constant checks!

@aidanmacgregor
Copy link

aidanmacgregor commented Jun 13, 2022

not entirely sure will try targeting 32 bit specifically, current timings are coded as follows, IF NO INTERNET = ping (500ms timeout), wait (500ms), Ping (500ms Timeout), Run Selected Login IF INTERNET Ping (Timeout Not Relevant), Wait (1000ms), Loop Back To Ping

I don't think anyone still uses 32-bit, do they? Not sure why mine (x64) won't run it, to be honest, but then I haven't reformatted and reinstalled for years (used to do it every 6 months) so Windows has probably accumulated a whole load of icky stuff that gets in the way... The timing thing: I meant between checks, sorry. I have my current batch going every 2 minutes or so, which can give a fair bit of downtime if the network's rubbish but avoids getting things piled up with constant checks!

ahh its set to loop so if first test passes waits 1 second and runs the same single packet ping again :)

EDIT: v4 Windows Exe Now Available
https://github.com/aidanmacgregor/BT_Wi-fi_Autologin_-_OpenWrt_Windows.EXE_Linux_Chrome-OS_Android-Macrodroid

@Gadgetoid
Copy link

@aidanmacgregor also now using your script (OpenWRT service). Nice work, thank you! Though I swapped the config over to /etc/btwifi.conf since I'm not sure what owns rc.local on OpenWRT.

@aidanmacgregor
Copy link

@aidanmacgregor also now using your script (OpenWRT service). Nice work, thank you! Though I swapped the config over to /etc/btwifi.conf since I'm not sure what owns rc.local on OpenWRT.

Hey Awesome! Glad its Working Well For You, and i was under impression nothing touched it besides from the user :)

@adammcguk
Copy link

@shuckster With the SSID of BT WiFi hotspots now changing to "EE WiFi", will the cloud-connect plugin need to be altered, and if so, what is required?

@shuckster
Copy link

@adammcguk - Thanks for the report.

If you're already using the plugin, you can try modifying this line in this file in your local filesystem.

Change it from:

BT_SSID=${CC_WIRELESS_SSID_MATCH:-"BTWi-fi\|BTWifi-with-FON"}

To:

BT_SSID=${CC_WIRELESS_SSID_MATCH:-"EE WiFi\|BTWi-fi\|BTWifi-with-FON"}

I have a suspicion the space may cause issues, so if the above doesn't work, try:

BT_SSID=${CC_WIRELESS_SSID_MATCH:-"EE\ WiFi\|BTWi-fi\|BTWifi-with-FON"}

If you are able try this and check that it works, I'll update the plugin in the repo so others can benefit.

@adammcguk
Copy link

@shuckster I tried the 2nd way and I also changed the main config file in the cloud connect plugin, as it also references the SSID. Not sure if this was required but after doing both, it is working.

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