#!/bin/bash #wd=`dirname $0` #wd=`dirname $wd`/webgup wd=/data/webgup wwwreq="anareq.txt" locreq="anareq_done.txt" wwwsite="http://portal.eiscat.se/db" export PATH=$PATH:/usr/local/bin export EISCATSITE=web fsiz() { filesize=`ls -l $1 | awk '{print $5}'` #return `ls -l $1 | awk '{print $5}'` } mail_it() { # mailx -s "Analysis results" -r "GUISDAP " $* <" $* </dev/null then echo "Could not reach HQ" exit 0 elif cmp -s $wwwreq $locreq then #echo "All already done" exit 0 else QUERY_STRING=`comm -23 $wwwreq $locreq | head -n1` fi fsiz $wwwreq nsiz=$filesize fsiz $locreq if [ -z "$QUERY_STRING" ] || [ $nsiz -lt $filesize ] then echo "New list" cp $wwwreq $locreq exit 0 fi echo $QUERY_STRING >> $locreq eval $QUERY_STRING fi maxsize=10000000 atpos=`expr index "$resultpath" "@"` if [ -z $resultpath ] || [ $atpos -eq 0 ] then echo "Nowhere to send results" mail= trusted=1 cd $resultpath else mail=1 trust if [ $maxfsize ] then maxsize=$(($maxfsize*730000)) #uuencoding maxes file ~27% bigger fi fi rundir=`date +%y%m%dw%H%M` if [ -d $rundir ] then rm -rf $rundir fi mkdir $rundir cd $rundir if [[ "$datapath" =~ .*"http".* ]] then for tar in $datapath do wget -O - "$tar" 2>/dev/null | tar xf - done ls | grep information | xargs rm -rf datapath=`ls` rmdata=1 else rmdata= fi if [ -z $datapath ] then echo "No data defined" exit 1 fi gfdfil=gfd.m cat << EOF > $gfdfil name_expr='$name_expr'; siteid=$siteid; data_path='$datapath'; result_path='AUTO'; t1=[$t 0 0 0]; t2=[$t 24 0 0]; rt=0; intper=$intper; path_exps=[path_GUP '/exps/']; figs=[0 0 0 0 1]; expver=$expver; extra='analysis_HDF=1;#$extra'; EOF #guisdap -tg $gfdfil " -c /opt/matlab7/etc/license.dat" >gupout.txt guisdap -tg $gfdfil >gupout.txt rm $gfdfil gzip -9 gupout.txt filelist="gupout.txt.gz" resdir=`ls -d [12]* 2>/dev/null` if [ $resdir ] then if [ $rmdata ] then rm -r $datapath fi Edir=`ls -d $resdir/EISCAT* 2>/dev/null` if [ $Edir ] then mv $Edir/*.hdf5 . gzip -9 *.hdf5 filelist="`ls *.hdf5.gz` $filelist" mv $Edir/*.tar.gz . if [ $trusted -eq 1 ] then filelist="`ls *.tar.gz` $filelist" fi fi rm -rf $resdir fi flist="" for fil in $filelist do fsiz $fil if [ $filesize -gt $maxsize ] then split -db $maxsize $fil $fil. flist="$flist `ls $fil.??`" else flist="$flist $fil" fi done nsiz=0 matt="" for fil in $flist do fsiz $fil if [ $((nsiz+filesize)) -gt $maxsize ] && [ $nsiz -ne 0 ] && [ $mail ] then mail_it $matt -- $resultpath sleep 30 matt="" nsiz=0 fi matt="$matt -a $fil" nsiz=$((nsiz+filesize)) done if [ $mail ] then mail_it $matt -- $resultpath else echo $filelist fi cd .. #rm -rf $rundir