saba
Estrat

Desconnectat
Missatges: 10
|
I $datafile quin valor té?
dons no ho sé, només veig la variable dintre dels "if", pel que sembla es construeix en base la la data actual
el arxius son
-rw-r--r-- 1 www-data www-data 29K 2007-06-09 18:15 /mnt/sata1/oregon/data/in_20070609.dat -rw-r--r-- 1 www-data www-data 17K 2007-06-09 18:15 /mnt/sata1/oregon/data/out_20070609.dat -rw-r--r-- 1 www-data www-data 19K 2007-06-09 18:15 /mnt/sata1/oregon/data/rain_20070609.dat -rw-r--r-- 1 www-data www-data 68K 2007-06-09 18:15 /mnt/sata1/oregon/data/wind_20070609.dat i el meu wmrplot.cgi es
#!/usr/bin/perl -wT # # $Id: wmrplot.cgi,v 1.6 2001/08/01 17:15:40 lukas Exp $ # # Copyright (C) 2000, 2001 Lukas Zimmermann, Basel, Switzerland # # This program is intended to run as CGI script. # It uses gnuplot to create png graphics from weather data files recorded # by wmr918d. # This script doesn't run with apache mod_perl, use external perl interpreter. # # TODO: # - # # $Log: wmrplot.cgi,v $ # Revision 1.6 2001/08/01 17:15:40 lukas # bugfix: # - existance test of file in_yyyymmdd.dat was totally nonsense. # # Revision 1.5 2001/07/28 13:27:48 lukas # add: # - for indoor baro/temp/humid sensor it is looked for a data file with a # name 'ins_yyyymmdd.dat' if 'in_yyyymmdd.dat' is not found. # # Revision 1.4 2001/02/26 03:42:07 lukas # solved scaling problems with the weather plots. # # Revision 1.3 2001/02/26 03:27:57 lukas # moved gnuplot scaling command to the top of the command list. # # Revision 1.2 2001/02/26 02:11:51 lukas # added wind direction plot. #
#use strict;
$ENV{PATH} = "/bin:/usr/bin:/usr/local/bin"; $gnuplot = "/usr/local/bin/gnuplot";
$datafilepath = "/mnt/sata1/oregon/data/"; $timecol = 1; $namecol = "test";
%FORM_DATA = (); $query_string = $ENV{"QUERY_STRING"}; if ($query_string) { # non empty query_string: process it, fill into hash @key_value_pairs = split(/&/, $query_string); foreach $key_value (@key_value_pairs){ ($key, $value) = split(/=/, $key_value); # replace `+' with space characters $value =~ tr/+/ /; # interpret any hex coded characters $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # remove comment strings $value =~ s/<!--(.|\n)*-->//g; # place value in associative array (key-indexed hashtable) $FORM_DATA{$key} = $value; } }
(undef, undef, undef, $mday, $mon, $year) = localtime(time); # today date string with four digit year for file names of today's file $date_str = sprintf "%d%02d%02d", $year + 1900, $mon + 1, $mday; # today date string with two digit year for plot legend $date_str2 = sprintf "%02d/%02d/%02d", $year - 100, $mon + 1, $mday;
$scale = "";
if ($FORM_DATA{plot} eq "outtemp") { $datafile = "out_$date_str.dat"; $datacol = 4; $range = "-10:30"; $pltln = "\"$datafilepath$datafile\" using $timecol:$datacol notitle"; } elsif ($FORM_DATA{plot} eq "outhumid") { $datafile = "out_$date_str.dat"; $datacol = 6; $range = "0:100"; $pltln = "\"$datafilepath$datafile\" using $timecol:$datacol notitle"; } elsif ($FORM_DATA{plot} eq "press") { $datafile = "in_$date_str.dat"; if (!(-e $datafilepath$datafile)) { $datafile = "ins_$date_str.dat"; } $datacol = 9; $range = "950:1050"; $pltln = "\"$datafilepath$datafile\" using $timecol:$datacol notitle"; } elsif ($FORM_DATA{plot} eq "wind") { $datafile = "wind_$date_str.dat"; $datacol = 5; $datacol2 = 7; $range = "0:30"; $pltln = "\"$datafilepath$datafile\" using $timecol:$datacol notitle with impulses"; } elsif ($FORM_DATA{plot} eq "wdir") { $datafile = "wind_$date_str.dat"; $datacol = 4; $range = "0:360"; $pltln = "\"$datafilepath$datafile\" using $timecol:$datacol notitle with points ps 0.5"; $scale = "set ytics 45"; }
print "Pragma: no-cache\n"; print "Content-type: image/png\n\n"; open PLOT, "|$gnuplot"; print PLOT "reset\n"; print PLOT "set terminal png color\n"; print PLOT "set size 0.8,0.4\n"; print PLOT "set output\n"; print PLOT "set noautoscale\n"; print PLOT "set xdata time\n"; print PLOT "set timefmt \"%y/%m/%d %H:%M:%S\"\n"; print PLOT "set xrange [\"$date_str2 00:00:00\":\"$date_str2 23:59:59\"]\n"; print PLOT "set yrange [$range]\n"; print PLOT "set format x \"%H:%M\"\n"; print PLOT "set grid\n"; print PLOT "set data style lines\n"; print PLOT "set linestyle 1\n"; if ($scale) { print PLOT "$scale\n"; } print PLOT "plot $pltln\n"; pipe (STDOUT, PLOT); close PLOT;
|