Running .sh file inside a shell script

Hello,

You might help a newbie like me, I am trying to run a .sh inside my shell script. After running that I need to execute below commands. Here's how my scripts looks like. Hope you can help:

#!/bin/sh
cd $ORACLE_HOME/owb/bin/unix
./OMBPlus.sh ---> goes to OMB+> directory
cd /app/mes_dwh/omb --> this needs to be executed while inside OMB+>
source execute_all.tcl --> need to be executed while inside OMB+> 
exit ---> need to exit to execute another command 

Thanks in advance....

Please use code tags as demanded in forum rules.

What does not work in your above script? Any error messags?

Do you know that you can run|source a program by its pathname, without prior cd ?

#!/bin/bash
$OARCLE_HOME/owb/bin/unix/OMBPlus.sh
source /app/mes_dwh/omb/execute_all.tcl

To execute something, you need

  • either a good path, relative or absolute, or have it in a directory in your $PATH,
  • it must have execute permissions to you, and
  • if it is a script, it needs a #! line with a good absolute path to the interpreter, and sometimes just one argument to make the interpreter happy, like -f for awk or sed.

thanks MadeinGermany.... I will try this....

The error I am getting is that after executing ./OMBPlus.sh....
it just stops there and do not do the cd command that I need to do.

Pls post the script ./OMBPlus.sh and / or logs of its execution. Or, provide us with a crystal bowl.

I would recommend to use these paths inside their corresponding script, don't mess with the main script. When it comes to call multiple scripts inside a wrapper script, all requirements should be fulfilled inside the called-script and not in main wrapper script. what you are messing up here is that writing down then paths for called-scripts and then a call is sent to them.
try executing them in a normal way as you would be doing them on command lineby either either

source

or

. /full/path/name

Yep, a cd in $ORACLE_HOME/owb/bin/unix/OMBPlus.sh
does not have an affect on the calling script (parent process),
unless it is included with

source $ORACLE_HOME/owb/bin/unix/OMBPlus.sh

or

. $ORACLE_HOME/owb/bin/unix/OMBPlus.sh

Hello MaidinGermany,
I re-write my code as below, please advise if this is ok. Thanks.

#!/bin/sh -fb
cd $ORACLE_HOME/owb/bin/unix/
./OMBPlus.sh
source /app/mes_dwh/test/$plugin/$plugin/$plugin/$plugin/omb/delete_all.tcl

Yes try it.
And also

#!/bin/sh -f
. $ORACLE_HOME/owb/bin/unix/OMBPlus.sh
. /app/mes_dwh/test/$plugin/$plugin/$plugin/$plugin/omb/delete_all.tcl

sh does not need a -f like sed and awk, and in fact it affects globbing, -b is only effective interactively, when there is job control, but sometimes we put in a -x for debug to see what it is doing.

-f Disable pathname expansion.

-b Report the status of terminated background jobs immediately, rather than before the next primary prompt. This is effective only when job control is enabled.

The effect of first line $!xxxx is a new command: xxxx "$0" "$@"

The man page for sed and awk says to run a script file use -f, but for sh it says just put it on the command line.