#!/usr/bin/perl print "Content-type: text/html\n\n"; use HTTP::Request::Common qw(POST GET); use HTTP::Headers; use LWP::UserAgent; use MIME::Base64; # 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 $encoded = encode_base64('admin:cisco123'); my $url = "https://192.168.151.156/admin/cisco_api.jsp"; # Params required for the POST... my $req = POST $url, 'Authorization' => "Basic ".$encoded, Content => [ op => "addmac", mac => "000112233445", ip => "192.168.151.1", type => "userole", role => "all", desc => "Dummy testing entry" # 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;
Updated: Jan 24, 2005Document ID: 63593