Automate Login to Tikona Broadband(Python on Windows)

@Marcus Fenix Now that we've got the script working and its time to try on OpenWrt. I'm not exactly sure about the steps to go but with my little knowledge think as follows..

1. Install python-full on OpenWrt
2. Install Mechanize
3. Copy the Tikona.py script to root or /usr/bin (not sure) folder of the router
4. Add the script path to crontab to make it executable after boot process.

Please check the steps and correct me If I'm wrong.

PS: Got one doubt, does it have to be python-full or light and basic versions will work?.

Thank you :)


I think if you have the spare space you can go ahead with point 1 and if point 2 is okay(i.e. Mechanize is installed properly)
you can go ahead with the point 3./usr/bin should be okay.

Just give all permissions to everybody on the .py file to avoid any issues.

chmod 777 /usr/bin/Tikona.py

As to point 3 I guess the boot process cron job will execute the script.But this will be a one time affair and if you are logged out after say 10-12 hrs you will have to reboot the router to login again(or do it manually via browser).

I would suggest creating a small shell script which loops to check internet connectivity via pinging google.

In case google cannot be pinged the login python script is triggered.
 
@Marcus Fenix was away and just back at home. Forgot to tell you, yesterday night I've tested the script couple of times to check the consistency. Something seems to be the problem as again the error showed up and had to revert back to https and worked. Not sure exactly but I'm actually thinking of some logic to overcome and also thought of curl script. Anyway give me some time I'll make my mind and get back to you ASAP.
 
I checked the link you sent.Can you edit it to ask if anybody is using mechanize on OpenWRT Python.
If sudo easy_install mechanize is okay then we can go ahead and use this shell to loop endlessly,check Internet and execute the script.
I modified the shell from your link
http://www.electronicsfaq.com/2014/01/automating-web-login-using-openwrt.html

As to the https/http issue I cannot replicate it from my side as in Kolkata https works flawlessly without any issues.


# Send two Ping request packets and 4 seconds timeout
return_value=$(ping -c 2 -W 4 www.google.com)
return_value=$?
# Return code for ping are taken from
# ./OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/include/sysexits.h

case $return_value in
0) #Ping reply received
logger "Ping result: ONLINE"
;;
1) #Ping sent but reply was not received
logger "Ping result: OFFLINE (Ping reply not received), Logging into Tikona..."
python Tikona.py -u 111XXXXXXX -O /dev/null
;;
*) #Error
logger "Ping result: OFFLINE (ping return code: $return_value), Logging into Tikona..."
python Tikona.py -u 111XXXXXXX -O /dev/null
;;
esac
 
@Marcus Fenix Thanks for the reply. Yes I've added the reply to the same OpenWrt forum post asking if any one uses both under OpenWrt.

For me like said this code is working perfect.
Code:
sudo easy_install mechanize

Sorry lost you, what exactly I have to do with the above shell script?. Shall I run it on terminal?.

Regarding the http/https think something is wrong with in my system coz recently I installed HTTPS Everywhere browser plugin which messed up I guess. Even in my browser some links are not opening properly had to change links manually.

@Marcus Fenix Sorry I understood now. I got to use your shell script and follow the steps in the reference link above and test it. Right?
 
Last edited by a moderator:
@Marcus Fenix Thanks for the reply. Yes I've added the reply to the same OpenWrt forum post asking if any one uses both under OpenWrt.

For me like said this code is working perfect.
Code:
sudo easy_install mechanize

Sorry lost you, what exactly I have to do with the above shell script?. Shall I run it on terminal?.

Regarding the http/https think something is wrong with in my system coz recently I installed HTTPS Everywhere browser plugin which messed up I guess. Even in my browser some links are not opening properly had to change links manually.

@Marcus Fenix Sorry I understood now. I got to use your shell script and follow the steps in the reference link above and test it. Right?
Yes.

Execute the shellscript manually from the console and if it is okay add it to the startup crontab job as discussed in the links you shared.
 
Yes.

Execute the shellscript manually from the console and if it is okay add it to the startup crontab job as discussed in the links you shared.

First try got this error

Code:
Usage: Tikona.py -u <username>

Tikona.py: error: no such option: -O

because I tried with one of these !/bin/bash & !/bin/sh at the beginning of the code. In the second try removed it and it worked but the thing is once I paste the code need to press return to confirm. And again tried third time to check the consistency but the same error showed up.

So whats is our next step now, think we're close to make it happen!
 
In Unix the best case is to call up the executable paths in case they are not present in bash profile file which is the configuration file used by your user id.
Go to your home path and run ls - ltra
This will show the .bash_profile and .bashrc files
Enter the path to the python executable (i.e. The package you installed) in the profile and rc files and restart to initialize the configuration.
In the SHELLSCRIPT I have given make changes like calling the path of the python file like /usr/opt/Tikona.py instead of calling the python file directly
 
First try got this error

Code:
Usage: Tikona.py -u <username>

Tikona.py: error: no such option: -O

because I tried with one of these !/bin/bash & !/bin/sh at the beginning of the code. In the second try removed it and it worked but the thing is once I paste the code need to press return to confirm. And again tried third time to check the consistency but the same error showed up.

So whats is our next step now, think we're close to make it happen!
Did you succeed in automating the process from OpenWRT?
 
Did you succeed in automating the process from OpenWRT?

Hi Marcus,

Sorry for not getting back. Well the answer to your question is both yes and no. After I left form here started working with other friend on the same issue and he helped with cron job script and at first few instances it worked without any issues and then after it wasn't.

I really can't tell whether the fault lies within the code or the Tikona dhcp server itself and haven't had much time to investigate as my busy days still continuing.Anyway to investigate this think some one using Tikona with OpenWrt setup should test it and report back. However I might not be able to reply to you in next 7-10 days so feel free to share your inputs here and I'll get back to you when I check.

Please find the attached scripts which I've used.
 

Attachments

  • Tik.zip
    2.2 KB · Views: 274
Back
Top