#!/bin/csh -f

set fecha=`date +%Y%m%d`
set hora=`date +%H`

#set URL='http://meteoarmada.directemar.cl/prontus_meteo/site/artic/20151128/imag/FOTO_MIX_RESULT20151128141737.jpg'
set URL='http://web.directemar.cl/met/jturno/cartas/imagen.jpg'

cd /home/matlab/hw_dynamic/SERVIMET/
cd cartas_color

foreach hracb ( 06 12 18 )

if ( ${fecha}${hracb} < ${fecha}${hora} ) then

if ( -e "${fecha}_${hracb}" ) then
    echo "${fecha}_${hracb} exist"
else 
    echo "${fecha}_${hracb} does not exist"
    wget ${URL} -O ${fecha}_${hracb}
endif
endif
end

# 45 3,4,5,9,10,11,15,16,17,21,22,23 * * * /hw_dynamic/SERVIMET/servimet.csh

