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
- 3039 reads








Comentarios recientes
10 years 10 weeks ago
10 years 34 weeks ago
10 years 34 weeks ago
10 years 34 weeks ago
11 years 49 weeks ago
13 years 5 weeks ago
13 years 5 weeks ago
13 years 6 weeks ago
14 years 2 weeks ago
14 years 9 weeks ago