Bash Shell Script Exit Codes

Here is my daily stupid question:

How can I tell a script to only execute if the other scripts exits successfully?

So "script A" executes and it executes successfully (0),then "script B" will run

or else

"script A "executes and it exits unsucessfully (1) then "script B" will read return code (1) and will not execute

Not exactly what you require, but the normal way of doing things:
In a controlling script:

scriptA && scriptB

The "&&" in Shell says only continue if the previous command returned exit status zero. Because scriptB never executes if scriptA fails, this probably does not match your requirement.

Resolution:

A Boolean operator "AND" (&&)

ex.

my_script_A.sh && my_script_B.sh

It is more than AND: it means after successful execution of previous program only

Assuming the scripts exit with various return codes, you may want to print a messages based on that or take other actions base don the return code. Use the shell built-in variable of "$?" which is the return code of the last command run:

#!/usr/dt/bin/dtksh

scripta
rc=$?
if (( $rc != 0 )); then
  print "Scripta failed with return code $rc"
  exit 1
else
  scriptb
  rc=$?
  if (( $rc != 0 )); then
    print "Scriptb failed with return code $rc"
    exit 2
  fi
fi

exit 0

If you need to test for various return codes a case statement that acts based on the return code may work for you too.

good stuff.

That is not a booean "and". That is just a coincidence of syntax.
Kernighan and Ritchie (RIP) realised that you can use context to determine syntax.