Modify Script: statctl.sh to Handle Different Versions Of Stat Oracle Agent

In the Process of upgrading To Stat version 6.2 and need current version and new version of Stat Oracle Agent running on the same host.

Can it be modified to handle this situation?   I modified the script as follows and it is working well for me.

statctl.sh shell script needs to do a better job in this situation when you need two different versions of Stat running.

Current version of Function getPID returns two OS Process IDs.   See below the change I made in green to better handle two agents running.

getPID () {
envCode=$1
if [ $PLATFORM = "HP-UX" ]
then
    pid=`ps -efx | grep "DSTAT=$envCode " | grep -v grep | awk '{print $2}'`
else
    ### pid=`ps -ef | grep "DSTAT=$envCode " | grep -v grep | awk '{print $2}'`   <====  This is the original command used to detect if Stat Oracle Agent is running
    pid=`ps -ef | grep "Dconfigfile=$cfgFile " | grep -v grep | awk '{print $2}'`       <===== This is the modification I made.
fi
echo $pid
}

+++++  Below are the two different version of Stat Oracle Agent running on the same host

tp_cgis+ 1931 1 0 Apr02 ? 00:00:00 tee -a /u01/3rdparty/stat62/log/ODCGI2I-fatal.err
tp_cgis+ 1932 1931 0 Apr02 ? 00:07:37 ./java -DSTAT=ODCGI2I -Xms256m -Xmx512m -Dconfigfile=/u01/3rdparty/stat62/conf/statDev.conf -Dcmdconfig= -DSTAT_HOME=/u01/3rdparty/stat62 -Dfile.encoding=UTF-8 com.quest.stat.oracle.OAStatAgent ODCGI2I

tp_cgis+ 25994 1 0 11:16 pts/2 00:00:00 tee -a /u01/3rdparty/stat581/log/ODCGI2I-fatal.err
tp_cgis+ 25996 25994 51 11:16 pts/2 00:00:03 ./java -DSTAT=ODCGI2I -Xms256m -Xmx512m -Dconfigfile=/u01/3rdparty/stat581/conf/stat.conf -Dcmdconfig= -DSTAT_HOME=/u01/3rdparty/stat581 -Dfile.encoding=UTF-8 com.quest.stat.oracle.OAStatAgent ODCGI2I

pid=`ps -ef | grep "DSTAT=ODCGI2I " | grep -v grep | awk '{print $2}'`    <===== Original command

echo $pid
1932 25996   <==== Original commands returns two OS Process ID.   (Not Good)

pid=`ps -ef | grep "Dconfigfile=/u01/3rdparty/stat581/conf/stat.conf " | grep -v grep | awk '{print $2}'`    <==== New Command
echo $pid
25996          <====  New command searches on Stat.conf name.   New Version of stat is in a different directory along with the stat conf file.