Manejo de Multiples Dispositivos Ubiquiti
Codigo en estado Alpha:
#!/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;
- bitfrost's blog
- Login to post comments
- 2654 reads
Comentarios recientes
8 years 32 weeks ago
9 years 3 weeks ago
9 years 4 weeks ago
9 years 4 weeks ago
10 years 19 weeks ago
11 years 26 weeks ago
11 years 26 weeks ago
11 years 27 weeks ago
12 years 23 weeks ago
12 years 30 weeks ago