Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
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 at 16:48
1  
script1 && script2 && script3 && script4 – Jeff Schaller Mar 8 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 at 17:32
#! /bin/sh -
script1 &&
 script2 &&
 script3 &&
 script4

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

Or:

#! /bin/sh -
set -e
script1
script2
script3
script4

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

Or:

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

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.

share|improve this answer
    
Thanks Stephane.. I shall try these.. Will keep you posted (tomorrow.. I am off work now) – Khushbu Chauhan Mar 8 at 17:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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