#!/bin/sh dir=/home/dpavlin/zc/gnuplot/ set > /dev/shm/cgi.env echo "Content-type: image/svg+xml" echo #pn=$( basename $0 | sed 's/.cgi//' ) test -z "$QUERY_STRING" && QUERY_STRING='.' numbers=$( grep "$QUERY_STRING" $dir/../subvision-numbers.txt | head -1 ) pn=$( echo $numbers | cut -d' ' -f2 ) temp_corr=$( echo $numbers | cut -d' ' -f5 ) test -z "$temp_corr" && temp_corr=0.00001 offset=$( grep "^$pn" $dir/offset.txt ) offset_x=$( echo $offset | cut -d' ' -f2 ) test -z "$offset_x" && offset_x=0 offset_y=$( echo $offset | cut -d' ' -f3 ) test -z "$offset_y" && offset_y=0 set > /dev/shm/$pn.env cat $dir/by_day.sql | sed \ -e "s/2008050087/$pn/" \ -e "s/x_axis_angle/x_axis_angle + $offset_x/" -e "s/y_axis_angle/y_axis_angle + $offset_y/" \ -e "s/0.0001/$temp_corr/" \ | tee /dev/shm/$pn.sql \ | psql --username=dpavlin -A -F "," -t zc > /dev/shm/$pn.txt-by-day cat $dir/template.gnuplot | sed \ -e "s,axes.txt,/dev/shm/$pn.txt-by-day," \ -e "s,^set terminal.*$,set terminal svg," \ -e "s,^set output.*$,set output," \ > /dev/shm/$pn.gnuplot gnuplot /dev/shm/$pn.gnuplot #rm /dev/shm/axes.txt.$$ /dev/shm/axes.gnuplot.$$