Last active
December 9, 2015 19:18
-
-
Save MasWag/4315659 to your computer and use it in GitHub Desktop.
This is a script to login ECCS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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