I am trying to create a shell script that runs several scripts under CentOS 7. Each script starts with #!/bin/bash
. Each script is tested and can be run as a standalone shell script with no problem.
Content of scripts_all.sh
#!/bin/bash
set -x
sudo yum install g++ make binutils cmake openssl-devel boost-devel zlib-devel
sh script_1.sh # executes all the contents of script_1.sh
sh script_2.sh # does not executed any of the command in script_2.sh.
sh script_3.sh
sh script_4.sh
script_1.sh
#!/bin/bash
sudo yum install centos-release-scl
sudo yum install devtoolset-9-gcc*
scl enable devtoolset-9 bash
which gcc
gcc --version
script_2.sh
#!/bin/bash
sudo yum install centos-release-scl-rh
sudo yum-config-manager --enable centos-release-scl-rh
sudo yum install devtoolset-9
scl enable devtoolset-9 bash
It appears that ./scripts_all.sh
will successfully execute set -x
, sudo yum
, sh script_1.sh
but stops at sh script_2.sh
. It is worth noting that I can run sh script_2.sh
with no issue independent of scripts_all.sh
. I don't know why the rest of the scripts won't be run.
./scripts_all.sh
prints the lines of sh script_1.sh
and their executions but it never prints the lines of sh script_2.sh
.
Could someone kindly help?