Platinum Partner
java,groovy,devops,tips and tricks,wifi

A Groovy Script to Keep The Internet Cafe WiFi From Dropping

Have you ever been to an Internet Cafe and connected to the free WIFI? Have you found that after five minutes of activity the connection has been dropped and you have go through the License and Terms of Agreement again and again and again? Annoying isn’t it?

Well after experiencing this at Charlotte, NC Airport in the USA recently, I re-concocted the script that I wrote for the half-dozenth time. This time I decided I was going to blog it and save it for all time.
Here is a simple Groovy script to keep the Internet alive.

// Hang-up to Internet Connection Groovy Script
// Useful for Internet Cafe that drop WIFI connectivity through
// perceived lack of activity e.g. Starbucks / Hotels
// Peter Pilgrim
// 28 September 2012

def maxTimeout = 30000
def minTimeout = 15000

def domainList = [
    'gmail.com', 'google.co.uk', 'google.com', 'bbc.co.uk', 'cnn.com', 'java.oracle.com',
    'facebook.com', 'twitter.com', 'oracle.com', 'zen.co.uk', 'java.net', 'www.scala-lang.org',
    'plus.google.com', 'guardian.co.uk', 'linkedin.com', 'www.typesafe.com', 'www.yahoo.com',
    'www.ibm.com', 'www.apache.org', 'www.adobe.com', 'www.microsoft.com', 'www.stackoverflow.com',
    'www.apple.com', 'groovy.codehaus.org', 'java.oracle.com', 'www.telegraph.co.uk', 'www.jroller.com',
    'www.dell.com', 'www.samsung.com', 'www.amazon.co.uk', 'docs.oracle.com', 'www.infoq.com',
    'www.devoxx.com', 'www.qconlondon.com', 'www.smashingmagazine.com', 'en.wikipedia.com' ]

def count = 1
while (true) {
    int idx = (int)( Math.random() * domainList.size )    
    println "[$count]  nslookup ${domainList[idx]}"
    def process = "nslookup ${domainList[idx]}".execute()
    println "Found text ${process.text}"
    
    def sleepTime = (int)( minTimeout + Math.random() * ( maxTimeout  - minTimeout))
    Thread.sleep( sleepTime );
    
    ++count
}

// done

The script can be improved with a much larger set of domain names, perhaps I could machine generate the domain names from the Chrome Browser history, or something like this. That is about all I would do, except to parameterize the command line arguments. On Mac or Linux I just hit the terminal and type with auto completion of course groovy ~/hangon-to-internet.groovy

Now, the only thing to write is a similar script to keep the WIFI connection to the both your mobile phone and tablet alive. Answers on a post card please.


Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}