当在while循环中调用时,Shell脚本将无法正确运行

ctehm74n  于 2023-08-07  发布在  Shell
关注(0)|答案(1)|浏览(101)

以下shell脚本读取文件,但在执行esscs.sh时返回错误:Error: Could not find or load main class a

cd /u01/oracle/essbase/products/Essbase/EssbaseServer/bin/cli/
while read application; do
        if [[ $application = "" || $application = "#"* ]]
        then
                continue
        else
                ./esscs.sh login -user usr -password xxx -essbaseurl https://bla/essbase
                ./esscs.sh lcmexport -application $application
        fi
done < /tmp/exportLCM_applications.txt

字符串
下面的shell脚本工作正常:

cd /u01/oracle/essbase/products/Essbase/EssbaseServer/bin/cli/
./esscs.sh login -user usr -password xxx -essbaseurl https://bla/essbase
./esscs.sh lcmexport -application hardcodedapp


以下是esscs.sh的内容,其中包含Essbase的Oracle命令行实用程序(cli):

#!/bin/sh

export ERR_MSG_JAVA_REQUIRED="Install JDK8 and set JAVA_HOME variable to JDK8 installed location"

if [ -z "$JAVA_HOME" ]
then
    echo
    echo $ERR_MSG_JAVA_REQUIRED
    echo
    exit 1
fi

export JAVA_VERSION=$("$JAVA_HOME/bin/java" -version 2>&1 | awk -F '"' '/version/ {print $2}')

if [[ "$JAVA_VERSION" < "1.8" ]]
then
    echo
    echo You are using older java version $JAVA_VERSION
    echo $ERR_MSG_JAVA_REQUIRED
    echo
    exit 1
fi

export SCRIPT_DIRECTORY=$(dirname "$(readlink -f "$0")")
cd "$SCRIPT_DIRECTORY"

export CLI_HOME=.
export REST_CLI_HOME=$CLI_HOME/lib

export CLASSPATH=.:$REST_CLI_HOME/ess_rest_cli.jar:$REST_CLI_HOME/ess_es_server.jar:$REST_CLI_HOME/ess_japi.jar:$REST_CLI_HOME/ess_svp.jar:$REST_CLI_HOME/commons-cli.jar:$REST_CLI_HOME/commons-io.jar:$REST_CLI_HOME/jersey-client.jar:$REST_CLI_HOME/javax.ws.rs-api.jar:$REST_CLI_HOME/jersey-common.jar:$REST_CLI_HOME/hk2-utils.jar:$REST_CLI_HOME/hk2-apijar:$REST_CLI_HOME/javax.inject.jar:$REST_CLI_HOME/hk2-locator.jar:$REST_CLI_HOME/hk2-api.jar:$REST_CLI_HOME/javax-annotation-javax-annotation-api.jar:$REST_CLI_HOME/jackson-annotations.jar:$REST_CLI_HOME/jackson-core.jar:$REST_CLI_HOME/jackson-databind.jar:$REST_CLI_HOME/jackson-mapper-asl-1.9.2.jar:$REST_CLI_HOME/ojdl.jar:$REST_CLI_HOME/jersey-guava.jar:$REST_CLI_HOME/cglib.jar:$REST_CLI_HOME/jackson-core-asl-1.9.2.jar:$JAVA_HOME/db/lib/derby.jar:$REST_CLI_HOME/ojdbc8.jar:$REST_CLI_HOME/ess-platform-common.jar:$REST_CLI_HOME/datasource-model.jar:$REST_CLI_HOME/excel-core.jar:$REST_CLI_HOME/lz4-java.jar:$REST_CLI_HOME/avatica-core.jar:$REST_CLI_HOME/calcite-core.jar:$REST_CLI_HOME/calcite-linq4j.jar:$REST_CLI_HOME/protobuf-java.jar:$REST_CLI_HOME/janino.jar:$REST_CLI_HOME/json-path.jar:$REST_CLI_HOME/checker-qual.jar:$REST_CLI_HOME/jts-core.jar:$REST_CLI_HOME/commons-compiler.jar:$REST_CLI_HOME/guava.jar:$REST_CLI_HOME/failureaccess.jar:$REST_CLI_HOME/slf4j-api.jar:$REST_CLI_HOME/slf4j-nop.jar:$REST_CLI_HOME/commons-lang3.jar:$REST_CLI_HOME/ons.jar:$REST_CLI_HOME/oraclepki.jar:$REST_CLI_HOME/orai18n.jar:$REST_CLI_HOME/osdt_core.jar:$REST_CLI_HOME/osdt_cert.jar:$REST_CLI_HOME/simplefan.jar:$REST_CLI_HOME/ucp.jar:$REST_CLI_HOME/xdb6.jar:$REST_CLI_HOME/esscatalog-model.jar

rqenqsqc

rqenqsqc1#

我通过阅读文档解决了这个问题,其中说:
要执行多个CLI命令,请将它们添加到任何shell脚本并执行它。在您运行的任何包含CLI命令的脚本中,Oracle建议您在CLI登录语句之前包括以下指令:对于Windows:set ESSCLI_ID=%USERNAME%*%random%对于Linux:export ESSCLI_ID= whoami *$PPID这有助于存储会话信息,并在多个脚本并发运行时防止执行错误。
https://docs.oracle.com/en/database/other-databases/essbase/21/ugess/download-and-use-command-line-interface.html

相关问题