#!/usr/bin/env perl

use strict;
use warnings;

use WWW::Mechanize;
use LWP::ConnCache;

my $host = "http://" . shift() . ":81";
my $mech = WWW::Mechanize->new( autocheck => 1 );

$mech->conn_cache(LWP::ConnCache->new());

$mech->credentials("admin", "gavin" );
$mech->get($host);
print $mech->response->content. "\n\n";

# store street cred.
my $cred = $mech->response->request->header('Authorization');

$mech->add_header( Authorization => $cred );
$mech->add_header( Referer => "$host/menu.htm" );
$mech->get( "$host/svlc.htm" );
print $mech->response->content. "\n\n";

# fix up the uri in the auth string
#$cred = $mech->response->request->header('Authorization');

#$cred =~ s|uri=\"/\"|uri=\"/CHKVOLM\"|; # "
#$mech->add_header( Authorization => undef );

$mech->tick("IDE", '0');
$mech->tick("CFM", 1);
$mech->click_button(name=>"B1");
#print $mech->response->status_line . "\n\n";
