Skip to content

Instantly share code, notes, and snippets.

@MasWag
Last active December 9, 2015 19:18
Show Gist options
  • Save MasWag/4315659 to your computer and use it in GitHub Desktop.
Save MasWag/4315659 to your computer and use it in GitHub Desktop.
This is a script to login ECCS.
#!/usr/bin/ruby
require 'rubygems'
require 'mechanize'
require 'kconv'
require "pit"
username , password = ARGV
if (config = Pit.get("eccs-password")) == {} then
if ARGV.length < 2 then
print "username >"
username = $stdin.gets.chop
print "password >"
system "stty -echo"
password = $stdin.gets.chop
system "stty echo"
end
Pit.set("eccs-password",:data => {"username"=>username, "pass" =>password})
p ""
elsif ARGV.length < 2
username , password = config["username"] , config["pass"]
end
agent = Mechanize.new
top = agent.get(URI.parse('http://google.com'))
login_link = top.link_with(:text => 'GO')
login_page = login_link.click
login_page.forms[0].field_with(:name => 'user').value = username
login_page.forms[0].field_with(:name => 'pass').value = password
login_page.forms[0].click_button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment