PEAT Online Course -
How To Improve Your Personal Performance in Java work Technology

  • YOU + CONTROL
  • Focus
  • Autonomy
  • Proficiency
  • Purpose
  • Covid-19!!!
  • Deep Hidden Meaning
  • FREE updates
GET 75% OFF NOW
Your Promo code: TECHLAYOFF
Exclusively on
VIMEO ON-DEMAND

A Groovy Script to Keep The Internet Cafe’s WIFI Alive

26 October 2012 Comments off

2 minutes

370

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.

Well after expiring this at Charlotte Airport in the USA recently, I re-concocted the script that I wrote for the half-dozenth time. This time I 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 parameterise 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 mobile phone and tablet alive. Answers on a post card please.

+PP+

Hey all! Thanks for visiting. I provide fringe benefits to interested readers: checkout consultancy, training or mentorship Please make enquiries by email or
call +44 (0)7397 067 658.

Due to the Off-Payroll Working plan for the UK government, I am enforcing stricter measures on contracts. All potential public sector GOV.UK contracts engagements must be approved by QDOS and/or SJD Accounting. Please enquire for further information.