#!/bin/bash

DIRS=~/"test_data/data/"
DIRD=~/"/test_data/results/"

A=$1".dmp"
B=$1"_centrality"
echo $A, $B
function die {
   echo "stop tranalyzer"
   pkill tail
   pkill gnuplot
   pkill tranalyzer
   exit
}

trap die INT TERM EXIT

if [ $1 ]; then
   ./gpqsgplot $B &

   while true; do

      if [ ! `pgrep tranalyzer` ]; then
	  echo "start tranalyzer"
	  ~/tranalyzer2/trunk/tranalyzer2/src/tranalyzer -r $DIRS$A -w $DIRD$1
      else
	  echo "tranalyzer running"
      fi
      sleep 1

   done
else
      echo "gpqdemo file"
fi
