Tuesday, September 20, 2011

Automate irritating ISP login

Well recently my ISP updated their systems and made compulsory web login before giving access to any other site. I found this very frustrating and didnt liked it. Every time I start my modem I have to login to this ISP web login form.
So I just think to automate this process, I wrote a small python script to automate this login process. So as per my convenience I can put it in auto-run after login or whatever I want. Since I am lazy programmer I searched for a library which gave me easy manipulation of web forms. So I found mechanize module for python doing things which were necessary for this script. (Dont ask me why python , I dont want to start unother python Vs xyz Language fight. I like python very much so python :-) )

For easy usage of script I will briefly describe 5 parameters which are needed to be set one time before using this script.

loginURL = "http://login.example.com" # URL to Login form of ISP site

Here you have to put URL of the login page where the login form is shown

loginID = "myUserName" # ISP user name
loginPassword = "mYp4ssw0rd" # ISP Password

Quiet self explanatory : Username and password

loginFormName = "loginForm"

On the login page of the ISP site, check the html code for
tag put the name of the form in this location


successString = """NOW ACTIVATING YOUR SERVICES"""

Do a manual login and check the first page shown after login and copy any string from that page which is shown every time you login. This is used to check whether the login was successfull.

Comments are welcome.

Download script here
PythonScript ISPlogin.py

Monday, September 12, 2011

SL4A:The Scripting Layer for Android

SL4A enables it to support many scripting language
interpreters. In order to make practical use of SL4A, we will need atleast
the rudiments of one high-level scripting language such as Python, Ruby, Perl, Lua,
JavaScript, or BeanShell.

For me it meant ability to create and run python scripts on my phone without having to ROOT the phone. It makes possible to use lots of GUI like Checkboxes, Radio buttons, Inputbox very easily. I checked out some sample scripts and they were small and simple scripts just like normal python.

For ex. only 4 lines code was able to speak time using text-to-speech engine. Mind it two lines of them were import statements :D

import android
import time

droid = android.Android()
droid.ttsSpeak(time.strftime("%_I %M %p on %A, %B %_e, %Y "))



I found out about python scripting on android after months of buying the android phone :D
I feel ashamed of myself for not finding out this long ago. Well there were some battery problems with phone so had to give it back to service center two times. But it feels great now.

Better than that it allows directly creating & editing the scripts directly on phone also :-D

So I would be starting some scripting on python. If done anything interesting I will post it.