There are 4 shell scripts:

  1. Migrate a file from path-A to path-B (unix).
  2. This script triggers one powercenter work flow.
  3. This script triggers one IDQ job.
  4. This script deletes the file from path-B (refer point-1 script)

Now I need to create a shell script to call above mentioned scripts in sequence (Any script shall not start before previous is completed successfully).

I am absolutely new to unix.

  • Can you please provide more details? As it stands, this a very generic question and is unlikely to give you helpful answers. Details like how the scripts are executed currently, whether they need to be called from a particular directory, etc would be helpful. – Munir Mar 8 '16 at 16:48
  • 1
    script1 && script2 && script3 && script4 – Jeff Schaller Mar 8 '16 at 17:01
  • @munircontractor... Currently each script has to be triggered manually using bash.. Yes all scripts exist in a directory and called from same dir – Khushbu Chauhan Mar 8 '16 at 17:32
#! /bin/sh -
script1 &&
 script2 &&
 script3 &&

cmd1 && cmd2 runs cmd2 only if cmd1 succeeds. The exit status of a script is the exit status of the last run command.


#! /bin/sh -
set -e

set -e tells the shell to exit whenever a command fails (with the exit status of the failing command).


#! /bin/sh -
script1 || exit
script2 || exit
script3 || exit

cmd1 || cmd2 runs cmd2 if cmd1 fails. exit exits the shell with the exit status of the last command (so here of the failing script). You can use exit 1 to force the exit status to be 1.

  • Thanks Stephane.. I shall try these.. Will keep you posted (tomorrow.. I am off work now) – Khushbu Chauhan Mar 8 '16 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.