logic for executing defined seq in file and cmd in file

I have four files a,b,c,d which need to contain certain in the sequence a, b, c ,d , each file command which needs to be executed,

          what i m  in need is that to executed file and cmd in the defined order and if any of the command FAIL or throw ERROR, it  script shud come out telling which file and which ?

quite I m digging deep still didn't found correct way yet

Since you haven't shown how deep you've dug, I shall assume that you have familiarity with the basic commands and concepts.

Here's what you may want to do:

  • Ensure that each script returns a consistent exit code that defines success or failure.
  • Display the scripts in sorted order using ls and sort, since the sequence of execution is the same as sorted order.
  • Use a for loop to loop through them and source them, one per iteration.
  • Test the exit code $? right after the execution.
  • If the exit code indicates failure, print the script name and break out of the loop.

HTH,
tyler_durden

thxs tyler_durden for idea this how I implement it

looks good but I have given seq of file in automate , redirected the error in /var/tmp/error file but , is it possible to find to line no./ cmds in the file have the thrown the error which we getting in /var/tmp/error here is code

for i in `cat automate`
do
ksh +x $i 2>/var/tmp/error
if [ $? -ne 0 ];then
echo "+++++++++++++++++++++++++++"
echo "FOLLOWING SCRIPT IS FAILED see file /var/tmp/error"
echo $i
echo "+++++++++++++++++++++++++++"
#exec 2>>/var/tmp/error
exit
fi
done

-deleted-