#!/bin/sh

master=http://eo-virtual-archive4.esa.int/search/ASA_IM__0P/ASA_IM__0CNPDE20090412_092426_000000162078_00079_37207_1556.N1/atom
slave=http://eo-virtual-archive4.esa.int/search/ASA_IM__0P/ASA_IM__0CNPAM20080427_092430_000000172068_00079_32197_3368.N1/atom
wps_acc_point=http://eo-virtual-archive4.esa.int/wps/WebProcessingService
process_id=com.terradue.wps_hadoop.examples.gmtsar.GMTSARAlgorithm

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ]; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`
BASEDIR=`cd "$PRGDIR" >/dev/null; pwd`

sh $BASEDIR/wpsclient \
 -e \
 -u $wps_acc_point \
 -p $process_id \
 -Imaster=$master \
 -Islave=$slave \
 -a \
 -t 20000
