简体   繁体   English

用于部署plsql包的Shell脚本|| Sqlplus:找不到命令错误

[英]Shell script to deploye plsql packages ||Sqlplus: command not found error

I have created the following shell script for deploying all the packages and tables scripts mentioned below. 我已经创建了以下shell脚本,用于部署下面提到的所有包和表脚本。 I first entered teh directry by : 我首先是通过以下方式进入Directry的:

cd /home/test

Then i called my shell script sh XXHCM_OBJECT.sh 然后我叫我的shell脚本sh XXHCM_OBJECT.sh

#!/usr/bin/sh 

# Parameters to be accepted from command prompt
# Parameter 1 = Apps username/Password
# Parameter 2 = BOLINF username/Password
# Parameter 3 = Host name for the instance
# Parameter 4 = Port Number for the instance
# Parameter 5 = DB Name for the instance


#APPS_USER="$1"
#BOLINF_USER="$2"
#HOST_NAME="$3"
#PORT_NUMBER="$4"
#DB_NAME="$5"

LOGFILE="$CUST_TOP/XXHCM_OBJECTS.log"

#APPS_USERNAME=$(echo $APPS_USER|cut -f "1" -d /)
#APPS_PWD=$(echo $APPS_USER|cut -f "2" -d /)

#-
#-  reading program parameters
#-

echo "Enter APPS User: "

read APPS

echo "Enter APPS Password: "

stty -echo

read APPS_PWD

stty echo


echo "Enter Custom User: "

read CUSTOM

echo "Enter Custom Password: "

stty -echo

read CUSTOM_PWD

stty echo

echo "Enter Install Server (SID): "

read SID



APPS_USER="$APPS/$APPS_PWD@$SID"

CUSTOM_USER="$CUSTOM/$CUSTOM_PWD@$SID"


APPS_USERNAME=$(echo $APPS_USER|cut -f "1" -d /)

APPS_PWD=$(echo $APPS_USER|cut -f "2" -d /)

echo "" > $LOGFILE


echo "" > $LOGFILE
echo "Starting installation of XXHCM_OBJECTS - XXHCM_OBJECTS ..."
echo "Starting installation of XXHCM_OBJECTS - XXHCM_OBJECTS ..." >>$LOGFILE
echo "" >>$LOGFILE

echo "" >>$LOGFILE
echo "Copying Files To Appropriate Directories ..."
echo "Copying Files To Appropriate Directories ..." >>$LOGFILE
echo "" >>$LOGFILE


echo "Changing permissions ... " >> $LOGFILE
chmod 777 *.*
echo "Changed permissions ... " >> $LOGFILE

echo "">>$LOGFILE
echo "Creating Custom Package, Synonyms and Grants...">>$LOGFILE
echo "Creating Custom Package, Synonyms and Grants..."
echo "">>$LOGFILE


if sqlplus $APPS_USER @XXHCM_MAPPING_STG.sql
then
    echo "Insert data into entities table in APPS schema" >> $LOGFILE
    echo "Insert data into entities table in APPS schema"
else
    echo "Error in Insert data into entities table in APPS schema" >> $LOGFILE
    echo "Error in Insert data into entities table in APPS schema" 
fi
if sqlplus $APPS_USER @XXdiv_ASSIGNMENT_SUPERVISOR_STG.sql
then
    echo "Insert data into entities table in APPS schema" >> $LOGFILE
    echo "Insert data into entities table in APPS schema"
else
    echo "Error in Insert data into entities table in APPS schema" >> $LOGFILE
    echo "Error in Insert data into entities table in APPS schema" 
fi
if sqlplus $APPS_USER @XXHCM_STAGING_TO_I.pks
then
    echo "Package specification for package XXHCM_STAGING_TO_I created in APPS schema" >> $LOGFILE
    echo "Package specification for package XXHCM_STAGING_TO_I created in APPS schema"
else
    echo "Error in creating Package specification" >> $LOGFILE
    echo "Error in creating Package specification" 
fi

if sqlplus $APPS_USER @XXHCM_STAGING_TO_I.pkb
then
    echo "Package body created for package XXHCM_STAGING_TO_I in APPS schema" >> $LOGFILE
    echo "Package body created for package XXHCM_STAGING_TO_I in APPS schema"
else
    echo "Error in creating Package body" >> $LOGFILE
    echo "Error in creating Package body" 
fi
echo "">>$LOGFILE
echo "Package, Synonyms,grants and Tables created successfully">>$LOGFILE
echo "Package, Synonyms,grants and Tables created successfully"
echo "">>$LOGFILE


echo "Installation completed for XXHCM_OBJECTS - XXHCM_OBJECTS"
echo "Installation completed for XXHCM_OBJECTS - XXHCM_OBJECTS" >> $LOGFILE
# *****************************************************************************
# End of Script
# *****************************************************************************

But at the output it is giving me an error : 但是在输出它给了我一个错误:

sqlplus: command not found

Looks like you are missing the sqlplus installation location in your PATH. 看起来您在PATH中缺少sqlplus安装位置。 Suppose your Oracle installation is on /opt/oracle/product/12.1.0/db_1 , sqlplus should be on /opt/oracle/product/12.1.0/db_1/bin , all you need to do is add to your script something like : 假设您的Oracle安装在/opt/oracle/product/12.1.0/db_1 ,sqlplus应该在/opt/oracle/product/12.1.0/db_1/bin ,您需要做的就是在脚本中添加类似:

export PATH=/opt/oracle/product/12.1.0/db_1/bin:$PATH

or like it is usually done, export a ORACLE_HOME variable and add it to the PATH, like 或像通常那样完成,请导出ORACLE_HOME变量并将其添加到PATH中,例如

export ORACLE_HOME=/opt/oracle/product/12.1.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM