#!/usr/bin/perl -w $DBHOST = "localhost"; $DBNAME = "temperature"; $table = "nattsjo_control"; $webreport = "http://www.rotary.nu/temp/nattsjo_control/report.php?pw=$password"; # create database temperature; # use temperature; # CREATE TABLE nattsjo_control (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, # time DATETIME, type VARCHAR(15), temp SMALLINT, PRIMARY KEY(id)); # INSERT INTO nattsjo_control VALUES (null, now(), 'indoor1_low', 0); # INSERT INTO nattsjo_control VALUES (null, now(), 'indoor1_high', 0); use DBI; use LWP::Simple; if (exists($ARGV[1])) { $low = int($ARGV[0]); $high = int($ARGV[1]); $sql1 = "UPDATE $table SET time = now(), temp = '$low' WHERE type = 'indoor1_low'"; $sql2 = "UPDATE $table SET time = now(), temp = '$high' WHERE type = 'indoor1_high'"; print "\n$sql1\n$sql2\n\n"; my $db = DBI->connect("DBI:mysql:$DBNAME:$DBHOST", $DBUSER, $DBPASS); $DBI::result = $db->prepare($sql1); $DBI::result->execute(); $DBI::result = $db->prepare($sql2); $DBI::result->execute(); my $webreport1 = $webreport . "&indoor1_low=$low&indoor1_high=$high"; my $content = get($webreport1); print "\n$webreport1\n\n"; print "$content\n\n"; } else { print "\nUsage: settrigger.pl low_limit*10 high_limit*10\n\n"; }