#sshuttle -r svoboda@golem.fjfi.cvut.cz 192.168.2.0/24
CSVFILE=csv/`date '+%d%m%y'`.csv
tail -n +2 $CSVFILE|awk -F '","|"' '{ print "echo \\\\GWQuantityFig{"$12"}>ActualPhysQuant;pdflatex QuantityFig.tex; convert -density 300 QuantityFig.pdf -quality 90 QuantityFigs/"$2".gif"}'|bash
# cp /golem/database/www/_static/QuantityFigs/
exit
#generate csv from pSQL
echo "\copy \"physicalquantities\" to '$CSVFILE' DELIMITER ',' CSV HEADER FORCE QUOTE * NULL 'NULL'"| psql -U golem golem_database;sed -i 's/,NULL/,"NULL"/g' $CSVFILE; head $CSVFILE
#create dirs
tail -n +2 $CSVFILE|awk -F '","|"' '{ print "mkdir -p /GW/"$12}' |bash;
#create PhysQuantDescript.page everywhere
tail -n +2 $CSVFILE|awk -F '","|"' '{ print "%pSQL export\n\\def\\PQIdentifier{"$2"}\n\\def\\PQDescription{"$3"}\n\\def\\PQLatex{"$4"}\n\\def\\PQUnit{"$5"}\n\\def\\PQRelation{"$6"}\n\\def\\PQValue{"$7"}\n\\def\\PQUncertainity{"$8"}\n\\def\\PQComment{"$9"}\n\\def\\PQLog{"$10"}\n\\def\\PQTag{"$11"}\n\\def\\PQAddress{"$12"}" > "/GW/"$12"/PhysQuantDescript.page"}'
tail -n +2 $CSVFILE|awk -F '","|"' '{ print "\\GWPhysQuantValueWithName{"$12"}\\newline"}' > AllGWPhysQuantValueWithName
# Generate tag specific form ....
rm AllTags.tex;for i in basic diagnostics technology vessel DAS infrastructure DischargeSetup plasma stabilisation; do TEMPCSVFILE=temp.csv;echo "\copy (SELECT * FROM \"physicalquantities\" WHERE tag LIKE '%"$i"%') to '$TEMPCSVFILE' DELIMITER ',' CSV HEADER FORCE QUOTE * NULL 'NULL'"| psql -U golem golem_database;sed 's/,NULL/,"NULL"/g' $TEMPCSVFILE|tail -n +2|awk -F '","|"' '{ print "\\GWPhysQuantValueWithName{"$12"}\\newline"}' > tex/"$i"TAGGWPhysQuantValueWithName.tex; echo "\start{"$i"}\GWinput{root/PhysicalQuantities/pSQL2GW/tex/"$i"TAGGWPhysQuantValueWithName.tex}\konec" >>AllTags.tex;done; ll;cat AllTags.tex
bash /GW/root/GW4reports/GW2reports.sh
cp pargrph.pdf ../GOLEMPhysQuant.pdf
tail -n +2 $CSVFILE|awk -F '","|"' '{ print "echo \\\\GWPhysQuantValueWithName{"$12"}>ActualPhysQuant;pdflatex IndividPhysQuant.tex; cp IndividPhysQuant.pdf /GW/"$12"/PhysQuant.pdf"}'|bash
# tail -n +2 $CSVFILE|awk -F '","|"' '{ print "cd /GW/"$12"/;bash /GW/root/GW4reports/GW2reports.sh;cd /GW/root/PhysicalQuantities/pSQL2GW/"}'|bash