Différences entre les versions de « Les scripts utiles »
Aller à la navigation
Aller à la recherche
(Page créée avec « Script pour changer le password d'une antenne <pre> #!/usr/bin/perl use FindBin qw($Bin $Script); use WWW::Mechanize; die "Syntax: $Script ... Changes the passwor... ») |
|||
Ligne 69 : | Ligne 69 : | ||
exit 0; | exit 0; | ||
</pre> | |||
Query SQL pour le summary financier | |||
<pre> | |||
select valid_from, valid_until, dbegin_may, dend_may, | |||
(dend_may - dbegin_may + 1) as nb_days_may, | |||
value_day, nb_days, | |||
value_day * (dend_may - dbegin_may + 1) as value_may from | |||
(select | |||
valid_from, valid_until, | |||
greatest(valid_from, '2016-05-01') as dbegin_may, | |||
least(valid_until, '2016-05-31') as dend_may, | |||
price, | |||
price / (valid_until - valid_from) as value_day, | |||
valid_until - valid_from as nb_days | |||
from invoices_elts | |||
where valid_until >= '2016-05-01' and valid_from <= '2016-05-30') | |||
as may; | |||
</pre> | </pre> |
Version du 20 février 2016 à 00:19
Script pour changer le password d'une antenne
#!/usr/bin/perl use FindBin qw($Bin $Script); use WWW::Mechanize; die "Syntax: $Script ... Changes the password on 1 or more AirOS units. " unless @ARGV >= 6; my $user = shift @ARGV; my $op = shift @ARGV; my $np = shift @ARGV; my $rouser = shift @ARGV; my $ropass = shift @ARGV; my @addresses = @ARGV; open L, ">>$Bin/$Script.log" or die "Unable to write to $Bin.log: $!"; sub l { print STDERR @_; print L @_; } for my $a (@addresses) { l "Changing password on $a\n"; my $mech = WWW::Mechanize->new(); my $entry; my $start = "http://$a/login.cgi?uri=/system.cgi"; $mech->get($start); $mech->field('username',$user); $mech->field('password',$op); $response = $mech->submit(); # to get login cookie if (!$response->is_success) { l $response->status_line, "\n"; } $mech->get(qq|http://$a/system.cgi|); $mech->field('NewPassword',$np); $mech->field('NewPassword2',$np); $mech->field('OldPassword',$op); $mech->field('ro_status', "enabled"); $mech->field('rousername', $rouser); $mech->field('roPassword', $ropass); $mech->field('hasRoPassword', "true"); $mech->click_button(name => "change"); $response = $mech->submit(); if (!$response->is_success) { l $response->status_line, "\n"; } $response = $mech->get(qq|http://$a/apply.cgi|); if (!$response->is_success) { l $response->status_line, "\n"; } } close L; exit 0;
Query SQL pour le summary financier
select valid_from, valid_until, dbegin_may, dend_may, (dend_may - dbegin_may + 1) as nb_days_may, value_day, nb_days, value_day * (dend_may - dbegin_may + 1) as value_may from (select valid_from, valid_until, greatest(valid_from, '2016-05-01') as dbegin_may, least(valid_until, '2016-05-31') as dend_may, price, price / (valid_until - valid_from) as value_day, valid_until - valid_from as nb_days from invoices_elts where valid_until >= '2016-05-01' and valid_from <= '2016-05-30') as may;