Skip to content

Instantly share code, notes, and snippets.

@vierbergenlars
Last active December 16, 2015 18:59
Show Gist options
  • Save vierbergenlars/5481384 to your computer and use it in GitHub Desktop.
Save vierbergenlars/5481384 to your computer and use it in GitHub Desktop.
Kotnet login script. Just run sudo ./install.sh
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
#!/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