Q:

exit status in shell script

I am running a application form the shell script. Now I like to know the exit status of the application to know whether it exit normally or abnormally ( crash etc). How I know it?
Example:
./mytestApp

A:

Bash stores the last process' exit value in the special variable $?.

A:

You can use special variable $? which contains an exit status of the last comand.

A:

$? contains the exit status of the last command executed. So, if the last command was ./mytestapp, $? would contain its exit status immediately after (note that you can only retrieve this value once and it must be retrieved immediately after the command whose exit status you want to know). You may want to capture it in a variable, e.g.
#!/bin/bash
./mytestapp
APPSUCCESS=$?
# Continue doing whatever it is you're doing

This all assumes that you're using bash (sh and zsh will work as well, IIRC).

