#!/usr/bin/perl # Copyright 2008-2009 M.Tavella # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA use Getopt::Std; use WWW::Mechanize; use strict; sub help { print "Usage: tremplinupdate -u USER -p PASS1 -n PASS2\n\n"; print "Where: USER is the Tequila user name\n"; print " PASS1 is the Tequila password\n"; print " PASS2 is the new password for tremplin.epfl.ch\n"; } my %opts = (); getopt('upn', \%opts); unless($opts{'u'} && $opts{'p'} && $opts{'n'}) { help(); exit 1; } my $tremplin_url = 'https://tremplin.epfl.ch/ssh.cgi'; my $tremplin_password = $opts{'n'}; my $tequila_username = $opts{'u'}; my $tequila_password = $opts{'p'}; my $mech = WWW::Mechanize->new( ); $mech->get($tremplin_url); $mech->field(password => "$tequila_password"); $mech->field(username => "$tequila_username"); $mech->click(); my $tequila_response = $mech->content(); if($tequila_response =~ "Tequila error : Authentification invalide.") { print STDERR "Error: can not authenticate with Tequila\n"; exit 1; } $mech->field(pwd1 => "$tremplin_password"); $mech->field(pwd2 => "$tremplin_password"); $mech->click(); my $tremplin_response = $mech->content(); unless($tremplin_response =~ "Mot de passe mis") { print STDERR "Error: something is wrong...\n"; exit 1; } exit 0;