Help with for loop within two scripts

Hello All,
I have a problem in executing the following - I have a monitor.sh that kicks off and then the config.sh which sends message to the monitor.sh. So If I recieve a Failed message, the monitor.sh will kill the config.sh process and outputs a message.

monitor.sh:
message= FAILED
DEPLOY_PID=ps -aef | grep create_config.sh | grep -v grep | awk {'print $2'}
MONITOR_PID=ps -aef | grep STEMonitor | grep -v grep | awk {'print $2'}
if [[ $message = FAILED ]]; then
kill -9 $DEPLOY_PID
echo "Deployment Failed"
echo " Please check the log for details"
kill -9 $MONITOR_PID
exit 1
fi

The problem is, I am not getting how to make monitor.sh run throughout in an infinite loop and keep checking config.sh and die after the deployment is done or failed. For the second part,I am killing monitor.sh after killing the config.sh and also adding another line to kill monitor.sh process at the end of config.sh

I am failing to loop monitor.sh to loop through on config.sh. Please help

-Chiru

I think you may want to search the forums for "co-process" or "coprocess" - this is a feature of ksh you will probably want to use.

In a simple way, I was implementing it in this way,
test.sh:
#!/bin/ksh
echo "test1"
./monitor.sh &
echo "test2"

monitor.sh
#!/bin/ksh
filename = $STE_ANT_DIR/deployment/logs/$APP_SHORTNAME_deployment.log
cd $STE_ANT_DIR/deployment
DEPLOY_PID=ps -aef | grep create_config.sh | grep -v grep | awk {'print $2'}
MONITOR_PID=ps -aef | grep STEMonitor | grep -v grep | awk {'print $2'}
message= $JAVA_HOME/java -classpath deploy.jar STEMonitor $filename
count=1
while ( count < 2 )
do
if [[ $message = FAILED ]]; then
kill -9 $DEPLOY_PID
kill -9 $MONITOR_PID
exit 1
fi
done

when I run monitor.sh:
./monitor.sh: cannot open 2: No such file or directory

is the error??
Any ideas please

Chiru

Please correct me if i am wrong.

You want to check continuously if the config.sh has sent "FAILED" message. If it does then you want to terminate the config.sh.

what i will suggest is set up a cron job which will check periodically and accordingly terminate the processes. This will help you to get rid of the infinite loop thing.