Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

A Groovy Script to Keep The Internet Cafe WiFi From Dropping

DZone's Guide to

A Groovy Script to Keep The Internet Cafe WiFi From Dropping

· DevOps Zone
Free Resource

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

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.


Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.

Topics:

Published at DZone with permission of Peter Pilgrim, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}