#!/bin/tcsh
if ("$1" == "") then
  set ini="tecs.ini"
else
  set ini="tecs_$1.ini"
endif
cd ~/tecs
if (! -e $ini) then
  echo ~/tecs/$ini not found
  echo ""
  set all=(tecs*.ini)
  echo "Usage:"
  echo ""
  if ("$all" == "tecs.ini") then
    echo "  startecs"
  else
    echo "  startecs <version>"
    echo ""
    echo "where <version> is one of"
    echo ""
    echo ${all:as/tecs_//:as/.ini//}
  endif
  exit
endif
ps waux | grep "TecsServer $ini" | grep -v grep > /dev/null
if ($?) then
  set nam=${ini:s/.ini//}
  ./keep_running ./TecsServer $ini -b ~/tecs/cfg/ -d ~/tecs/log/ -n $nam &
else
  echo "TecsServer is running"
endif

