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

问题描述 投票:0回答:1

以下 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 (cli) 的 Oracle 命令行实用程序:

#!/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
linux shell export command-line-interface essbase
1个回答
0
投票

我通过阅读文档解决了这个问题:

要执行多个 CLI 命令,请将它们添加到任何 shell 脚本中并 执行它。在您运行的任何包含 CLI 命令的脚本中,Oracle 建议您在 CLI 登录之前包含以下指令 语句: 对于 Windows:设置 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

© www.soinside.com 2019 - 2024. All rights reserved.