How to check succeesfull finish of a executable from the sheel script

Hi,

I want to know is there a way out wherein we can know that the C++ executable has finished its task.

Following is the steps:

1.Shell script calls a executable after setting all the env variables.

2.Now after the executable has done its job(basically to create some outpur files).The shell script needs to send out a mail with these output files as attachement.

Please help me in this asap.

If you can be sure that there will only be one process with the name of the c++ program running at any one time use something like:

start the c++ program...

str=`ps aux |grep <c++ name>|grep -v grep`
while [ ! "$str" = "" ];
do
sleep 60 # wait 1 minute and try again
str=`ps aux |grep <c++ name>|grep -v grep`
done;

... now deal with the files.

Sounds a bit complicated, from the original spec the following should work...

#!/bin/sh
run-c++-program
echo "done" | mailx -s "done" fred@bedrock