By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

How to know a executable has finished his task

P: 8
Hi frnds,

I want to know is there a way by which we can know that a C++ executable has finished its job in shell script.

My task is as follows:

1.Shell script calls a executable

2.Executable executes and performs its job of generating some reports.

Now i want my shell script to detect this that is C++ executable has completed its job so that shell script can send the reports as attachement.

Please help me urgently on this
Jan 4 '08 #1
Share this Question
Share on Google+
2 Replies

arne
Expert 100+
P: 315
Hi frnds,

I want to know is there a way by which we can know that a C++ executable has finished its job in shell script.

My task is as follows:

1.Shell script calls a executable

2.Executable executes and performs its job of generating some reports.

Now i want my shell script to detect this that is C++ executable has completed its job so that shell script can send the reports as attachement.

Please help me urgently on this
If the executable is not started in the background (or detaches itself from the shell or execves some other programs), the shell will not continue until the executable has returned. So, you should be able to simply do the mail transfer as the next command after the invocation of the executable.

Let me know if I missed the point here :)

arne
Jan 4 '08 #2

P: 13
I agree - unless the executable fails. You might consider using the return code to determine the success or failure of the process. Most processes in UNIX return zero (0) as success and I will continue assuming yours does too.

The shell script would look something like this:

Expand|Select|Wrap|Line Numbers
  1. your_c++_executable || {
  2.      error_handling_procedure
  3.      exit 1
  4.      }
  5.  
  6. procedure_to_get_ reports
  7.  
The ' || ' (or) is saying essentially: do the c++ process OR error out and exit. If the c++ process is successful (and returns 0), the shell would proceed to get reports. Hope this sheds additional light on the subject for you.
Jan 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.