我已经编写了一个脚本,它将在 Amazon Linux 2.0 上静默安装 Microstrategy
在我的主脚本中,我调用位于 /bin/ksh 中的 Microstrategy 安装脚本,而我的位于 /bin/bash 中
mstr_install.sh如下:
#!/bin/bash
#DATE 22-FEB-2019
#DISCRIPTION: IT will Install MSTR-11.1 with Silent Options using optins.txt file
DATE=$(date +"%Y-%m-%d_%T")
PATH="/app/soft/Installations/QueryReportingAnalysis_Linux/"
/usr/bin/mv "$PATH"options.txt "$PATH"options_backup."$DATE"
/usr/bin/cp /app/automation/mstr/options.txt "$PATH"
/usr/bin/chmod 777 "$PATH"options.txt
cd "$PATH"
bash setup.sh -silent -options options.txt
exit
并且setup.sh是供应商脚本,其中shebang行是
#/bin/ksh
我正在运行如下脚本:
#sh -x mstr_install.sh
并出现以下错误:
[root@a1-m022mstiap01 mstr]# sh -x mstr_install.sh
++ date +%Y-%m-%d_%T
+ DATE=2019-07-25_07:59:35
+ PATH=/app/soft/Installations/QueryReportingAnalysis_Linux/
+ /usr/bin/mv /app/soft/Installations/QueryReportingAnalysis_Linux/options.txt /app/soft/Installations/QueryReportingAnalysis_Linux/options_backup.2019-07-25_07:59:35
+ /usr/bin/cp /app/automation/mstr/options.txt /app/soft/Installations/QueryReportingAnalysis_Linux/
+ /usr/bin/chmod 777 /app/soft/Installations/QueryReportingAnalysis_Linux/options.txt
+ cd /app/soft/Installations/QueryReportingAnalysis_Linux/
+ /usr/bin/ksh ./setup.sh -silent -options options.txt
./setup.sh[879]: basename: not found [No such file or directory]
./setup.sh[882]: dirname: not found [No such file or directory]
./setup.sh[883]: cd: bad directory
./setup.sh[408]: uname: not found [No such file or directory]
Checking for running instances..../setup.sh[866]: ps: not found [No such file or directory]
../setup.sh[82]: cat: not found [No such file or directory]
...done.
./setup.sh[466]: mkdir: not found [No such file or directory]
Unable to check the Kernel size
+ exit
[root@a1-m022mstiap01 mstr]#
这是一个非常棘手的问题,如果有什么遗漏了请告诉我。
感谢 Santosh G。
答案1
这是错误的:
bash setup.sh -silent -options options.txt
通过使用“bash”启动脚本,您可以跳过she-bang。
我认为你需要这样做:
./setup.sh -silent -options options.txt
(设置可执行位)或
ksh setup.sh -silent -options options.txt
===
这是不好的行为:
PATH="/app/soft/Installations/QueryReportingAnalysis_Linux/"
我会为此使用一个与环境变量不同的特定变量名。这样做会给你带来麻烦。