Computer Association of SIUE - Forums

CAOS Forums => Questions and Answers => Topic started by: Justin Camerer on 2007-08-31T12:34:41-05:00 (Friday)

Title: SIUE Wireless Network Login Script
Post by: Justin Camerer on 2007-08-31T12:34:41-05:00 (Friday)
Is it just me, or does that wireless network login screen piss everyone off? Well, I am sick of seeing it, so I wrote a little script that will remedy that problem. Basically, it just attempts to go to google.com, and if it sees the login page, it just posts your username and password. After this logs in, you are free to browse the internet as you wish. I'm not sure if it'll work for me yet, but its a start.

The script is as follows:


#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'

m = WWW::Mechanize.new
m.get('http://www.google.com')

if m.page.body.index('REGISTERED USER')
  m.page.forms[0].user     = "jcamere"
  m.page.forms[0].password = "thisismypassword"
  m.page.forms[0].submit
end


To run it, you must have Ruby (http://www.ruby-lang.org/en/), Ruby Gems (http://rubyforge.org/frs/?group_id=126&release_id=11889), and the WWW::Mechanize gem (which can be installed with sudo gem install mechanize after you have Ruby gems installed).

After you do this, make the file executable with chmod, and set up a cron job to run this script every once in a while.
Title: Re: SIUE Wireless Network Login Script
Post by: JR on 2007-08-31T14:21:00-05:00 (Friday)
awesome
Title: Re: SIUE Wireless Network Login Script
Post by: Kit on 2007-08-31T21:16:58-05:00 (Friday)
QuoteTo run it, you must have Ruby, Ruby Gems, and the WWW::Mechanize gem (which can be installed with sudo gem install mechanize after you have Ruby gems installed).  After you do this, make the file executable with chmod, and set up a cron job to run this script every once in a while.

That's it? Really?  :roll:
Title: Re: SIUE Wireless Network Login Script
Post by: William Grim on 2007-09-01T11:56:29-05:00 (Saturday)
I'm not there to test that and see if it works with their HTTPS protocol, but if it does, you should package it into an exe with a config file for Windows users.  Either way, nice script.
Title: Re: SIUE Wireless Network Login Script
Post by: Justin Camerer on 2007-09-01T16:02:25-05:00 (Saturday)
Haha. Yeah, thats it. But, ruby is a great thing to have installed on your system anyway. Sorry, this was my 5 minute solution.
Title: Re: SIUE Wireless Network Login Script
Post by: Tony on 2007-11-19T01:23:24-06:00 (Monday)
Not sure about most of you, but for some reason most of the time when I am trying to get the Login screen to pop up by accessing a website, it doesn't always work the first time.  So, I just put this script in a loop that will keep trying to access google until it gets the login page.

Thanks, Justin!

#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'

m = WWW::Mechanize.new
m.get('http://www.google.com')


m.get('http://www.google.com') until m.page.body.index('REGISTERED USER')
m.page.forms[0].user     = "apieri"
m.page.forms[0].password = "yourpassword"
m.page.forms[0].submit

puts "\nDone!"