#!/bin/bash

if [ -z "$FEP_ENV" ]; then
  echo "Error: FEP_ENV is not set. Please set it first."
  exit 1
fi

RUNTIME_CF_FILE="$FEP_ENV/etc/runtime.cf"

while read LINE ; do
	if [ -n "$LINE"  ] ; then
		if [  ${LINE:0:1} != "#" ]; then			
			BINPATH=`echo $LINE | awk -F '^' '{printf $1}'`
			BINPATH=`echo "$BINPATH" | grep -o "[^ ]\+\( \+[^ ]\+\)*"`
#			echo $BINPATH
			BIN=`echo $LINE | awk -F '^' '{printf $2}'`
			BIN=`echo "$BIN" | grep -o "[^ ]\+\( \+[^ ]\+\)*"`
#			echo $BIN
			SPECIAL=`echo $LINE | awk -F '^' '{printf $4}'`
			SPECIAL=`echo "$SPECIAL" | grep -o "[^ ]\+\( \+[^ ]\+\)*"`
#			echo $SPECIAL
			
			SLEEPSEC=`echo $LINE | awk -F '^' '{printf $5}'`
			SLEEPSEC=`echo "$SLEEPSEC" | grep -o "[^ ]\+\( \+[^ ]\+\)*"`
#			echo $SLEEPSEC
			STARTFLAG=`echo $LINE | awk -F '^' '{printf $7}'`
			STARTFLAG=`echo "$STARTFLAG" | grep -o "[^ ]\+\( \+[^ ]\+\)*"`
#			echo $STARTFLAG		

#			if [ "`echo $STARTFLAG`" != "IGNORE_START" ]; then
				CMD_STR="  ps -w | grep `echo "'"``echo $BIN``echo "'"` | grep -v 'grep'"
				BIN2=`echo $BIN` 
				ps -ef | grep "$BIN2" | grep -v 'grep'
#			fi
		fi
	fi		
done < $RUNTIME_CF_FILE
