#!/bin/bash

#set -x

ferret -batch -script date.jnl

date1=`tail -n 2880 date.txt | head -n 1 | awk '{print $1}'`
date2=`tail -n 1   date.txt | head -n 1 | awk '{print $1}'`

rm -f date.txt

echo $date1 $date2

ferret -batch -script fig.jnl $date1 $date2

for file in *.eps ; do
 convert -antialias -background white -density 120 -flatten -quality 0 $file ${file%*.eps}.png
 optipng ${file%*.eps}.png
done

pwd=$PWD

HOST="www.climatodata.uliege.be"
USER="climatodata"
PASS="S@l@de2Fru1t5"
FTPURL="ftp://$USER:$PASS@$HOST"
LCD="$pwd"
RCD="."
#DELETE="--delete"
lftp -c "set ftp:list-options -a;
open '$FTPURL';
lcd $LCD;
cd /public_html/img-katabata
mput *.png"

