Last active
December 16, 2015 18:59
-
-
Save vierbergenlars/5481384 to your computer and use it in GitHub Desktop.
Kotnet login script. Just run sudo ./install.sh
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
apt-get install -y perl libwww-mechanize-perl | |
mv kotnet_login.pl /etc/NetworkManager/dispatcher.d/02kotnet | |
ln -s /etc/NetworkManager/dispatcher.d/02kotnet /etc/init.d/kotnet | |
update-rc.d kotnet defaults |
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/perl -w | |
use strict; | |
use WWW::Mechanize; | |
my $username="<Username>"; | |
my $password="<Password>"; | |
my $client = WWW::Mechanize->new(agent => "Mozilla/5.0"); | |
my $ip = qx|/sbin/ip addr show to 10.0.0.0/8|; | |
die if ($ip eq ""); | |
$client->get("https://netlogin.kuleuven.be/cgi-bin/wayf2.pl?inst=kuleuven&lang=en"); | |
$client->form_name("netlogin"); | |
$client->set_visible($username, $password) ; | |
$client->submit(); | |
$client->content =~ m/<rc=(\d*?) (.*?)( <.*)?>/i; | |
print "$1"; | |
if ($1 == 100) { | |
print " - Kotnet login OK\n"; | |
} | |
else { | |
print " - Kotnet login Error\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment