use LWP::UserAgent;
use Getopt::Long; #pick up parms
my $heattemp = “0”;
my $cooltemp = “0”;
$heattemp = sprintf(“%.0f”,$ARGV[0]);
$cooltemp = sprintf(“%.0f”,$ARGV[1]);
my $outfile = “vencntlstat.txt”; #status file
my $outln = “”;
if (($heattemp == “0”) or ($cooltemp == “0”)) {
$outln = “vencntlstat=1”;
open OUTPUT, “> $outfile” or die “Output file open error: $!”;
print OUTPUT $outln;
close OUTPUT;
exit;
}
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request ‘POST’,’http://192.168.2.148/control’;
$req->header(‘content-type’ => ‘application/x-www-form-urlencoded’);
my $query = “heattemp=” . $heattemp . “&” . “cooltemp=” . $cooltemp;
$req->content($query);
my $resp = $ua -> request($req);
if ($resp->is_success) {
my $message = $resp->decoded_content;
print “Received reply: $message\n”;
$outln = “vencntlstat=0”;
open OUTPUT, “> $outfile” or die “Output file open error: $!”;
print OUTPUT $outln;
close OUTPUT;
}
else {
print “HTTP POST error code: “, $resp->code, “\n”;
print “HTTP POST error message: “, $resp->message, “\n”;
$outln = “vencntlstat=1”;
open OUTPUT, “> $outfile” or die “Output file open error: $!”;
print OUTPUT $outln;
close OUTPUT;
}