#!/bin/ksh

command=$1
file=$2
base=$3
runtime=$4
PROGBASE=$5
arguments=""
shift
shift
shift
shift
shift

# Skip to the third argument
# Process the arguments following (as these are to be passed to the statistical tool)
until [[ $# -eq 0 ]]
do
   arguments=$arguments" "$1
   shift
done

# Run the statit command - assumes this is self-terminating
echo "Running statistics gathering: $PROGBASE/bin/$command with -x and -y arguments"
$PROGBASE/bin/$command -x $arguments 
sleep $runtime
$PROGBASE/bin/$command -y $arguments > $base/${command}.$file 2>&1
