#!\C:\strawberry\perl\bin use strict; use HTTP::Request::Common qw(POST GET); use HTTP::Headers; use LWP::UserAgent; use MIME::Base64; use Crypt::SSLeay; # set up the stuff my $ua = LWP::UserAgent->new(); # Set our own user-agent string! $ua->agent("CCAAgent/v3.5.8 CleanAccessManager API"); # Set the Basic Authentication credentials my $encoded = encode_base64('user:pass'); my $url = "https://somehost/admin/cisco_api.jsp"; # Params required for the POST... if (($ARGV[0] eq 'addmac') and defined($ARGV[1])) { my $req = POST $url, 'Authorization' => "Basic ".$encoded, Content => [ admin => "user", passwd => "pass", op => "addmac", mac => "$ARGV[1]", user => "i-command", provider => "pxebuild", type => "userole", role => "Authorized_Asset", desc => "Reset via icmd" # no comma here! ]; # Fire the cannon now ! my $res = $ua->request($req); # Get the error back from the server if any my $err = $res->status_line; if ($err != 200) { print "Server returned error: $err\n"; exit 1; } # Just print the whole stuff #print $res->as_string; # Just print the return html print $res->content; exit 0;