Here is a snip of the script:
ssh $(hostname | cut -f1 -d1)2 " echo 'Secondary Node ';
OH=$(env | grep ORACLE_HOME | cut -c13-55);
CN=$(env | grep CONTEXT_NAME | cut -c14-40);
cd $OH/appsutil/scripts/$CN;
./myscript.sh pass=****;
clear;
./myscript.sh pass=****;"
Error:
Error -ksh: hostname1/appsutil/scripts/erpaaps1_apps1s/myscript.sh: not found
What happens is that script evaluates the variables on the first machine before it ever SSHs to the second. When this happens it goes into the wrong directory (because it got the value from the first server and not the one it SSH'd to).
I have also tried the script this way:
ssh $(hostname | cut -f1 -d1)2 ' echo "Secondary Node ";
OH=$(env | grep ORACLE_HOME | cut -c13-55);
CN=$(env | grep CONTEXT_NAME | cut -c14-40);
cd $OH/appsutil/scripts/$CN;
./myscript.sh pass=****;
clear;
./myscript.sh pass=****;'
Error: -ksh: hostname1/appsutil/scripts/erpaaps1_apps1s/myscript.sh: not found
It still evaluates the variables from the first machine before ever running on the second.
If I take the script and try it on the remote machine locally it works as expected with the correct directories.