#!/opt/bin/perl -I/opt/ras21/lib
use Util;

use LWP::UserAgent;
$FILE = "sysprop.htm";
$FILE = "elemprop.htm";

if ($ARGV[0] && defined($ARGV[1]) ) {
  print "Testing tokens on $ARGV[0]...\n";
  $ip = $ARGV[0];
  $parm = $ARGV[1];
} else {
  print "Usage: testt3 <ip> <0/1>   # enter 0 or 1 for unit1 or unit2 \n";
  exit;
}

if (!Util->testIp($ip,3)) {
  print "ERROR: Cannot ping $ip\n";
  exit;
}

$url = "http://guest\@$ip/loopinf.htm";
$url = "http://guest\@$ip/sysprop.htm";

$url = "http://guest\@$ip/$FILE?unitIndex=$parm";
print "URL=$url \n";
$time = time;

$ua = new LWP::UserAgent;

#  $ua->agent("AgentName/0.1 " . $ua->agent);
#  $ua->proxy('http' => "http://cache-brm.Central.Sun.COM:8080");
#  $ua->credentials("http://diag210.central", "NobleGUI", "guest", "");

my $req = new HTTP::Request(GET => $url);

my $res = $ua->request($req);

if ($res->is_success) {
  $s = length($res->content);
#  print $res->content;
  print "GOT " . length($res->content);
  print $res->content;
} else {
  print "$FILE FAILED!";
}

print "bytes in " . (time - $time) . "secs\n";

