Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use WWW::Mechanize;
- use JSON qw/encode_json/;
- my $username = 'test';
- my $password = 'test';
- my $url = 'http://localhost:9990/management';
- my $method = WWW::Mechanize->new(autocheck => 1);
- my $data = encode_json {"operation" => "read-attribute","name" => "server-state", "json.pretty" => 1};
- $method->add_header('Accept'=>'text/plain');
- $method->add_header('Content-Type'=>'application/json');
- $method->credentials("localhost:9990","ManagementRealm", $username=>$password);
- $method->post($url, content=>$data );
- my $result = JSON::XS->new->allow_nonref->decode($method->content());
- print "$i - $result->{result}";
- [fspolti@my-laptop probes-temp]$ perl perl-probe.pl
- - running[
- #!/usr/bin/perl
- use WWW::Mechanize;
- use JSON qw/encode_json/;
- my $username = 'test';
- my $password = 'test';
- my $url = 'http://localhost:9990/management';
- my $method = WWW::Mechanize->new(autocheck => 1);
- my $data = encode_json {"operation" => "read-attribute","name" => "server-state", "json.pretty" => 1};
- $method->add_header('Accept'=>'text/plain');
- $method->add_header('Content-Type'=>'application/json');
- $method->credentials("localhost:9990","ManagementRealm", $username=>$password);
- for (my $i=0; $i<10; $i++) {
- $method->post($url, content=>$data );
- my $result = JSON::XS->new->allow_nonref->decode($method->content());
- print "$i - $result->{result}";
- }
- [fspolti@my-laptop probes-temp]$ perl perl-probe.pl
- Error POSTing http://localhost:9990/management: Unauthorized at perl-probe.pl line 18.
- 0 - running[f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement