在shell脚本中触发UNIX序列

时间:2016-03-02 17:49:02

标签: bash shell unix

我有一个shell脚本,我正在执行它来部署PL / SQL对象。环境中的包/表脚本。

现在我正在执行sh XX_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=XXHCM_STAG`date +%Y-%m-%d-%H:%M:%S`.log
LOG_PATH=`echo $CUR_DIR/$LOG_FILE`

#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 Install Server (SID): "

read SID



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


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

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


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

cp *.ldt $XXHCM_TOP/install

cp *.sql $XXHCM_TOP/sql 

cp *.pks $XXHCM_TOP/sql 

cp *.pkb $XXHCM_TOP/sql 

cp *.ctl $XXHCM_TOP/bin

cp *.prog $XXHCM_TOP/bin

echo   "">>$LOGFILE


echo   "">>$LOGFILE
echo "Files copied successfully !!! "
echo "Files copied successfully !!! "    "">>$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 @I_table_creation.sql
then
    echo "Custom itables created successfully in APPS schema"     "">>$LOGFILE
    echo "Custom itables created successfully in APPS schema" 
else
    echo "Error in creating custom  itables in APPS schema"     "">>$LOGFILE
    echo "Error in creating Custom itables  in APPS schema" 
fi

if sqlplus $APPS_USER @insert_entities.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 @insert_fields.sql
then
    echo "Insert data into insert_fields table in APPS schema"     "">>$LOGFILE
    echo "Insert data into insert_fields table in APPS schema"
else
    echo "Error in Insert data into insert_fields table in APPS schema"     "">>$LOGFILE
    echo "Error in Insert data into insert_fields table in APPS schema" 
fi


if sqlplus $APPS_USER @xx_cmp_thread.pks
then
    echo "Package specification for package xx_cmp_thread created in APPS schema"     "">>$LOGFILE
    echo "Package specification for package xx_cmp_thread created in APPS schema"
else
    echo "Error in creating Package specification"     "">>$LOGFILE
    echo "Error in creating Package specification" 
fi

if sqlplus $APPS_USER @xx_cmp_thread.pkb
then
    echo "Package specification for package xx_cmp_thread created in APPS schema"     "">>$LOGFILE
    echo "Package specification for package xx_cmp_thread created in APPS schema"
else
    echo "Error in creating Package specification"     "">>$LOGFILE
    echo "Error in creating Package specification" 
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
# *****************************************************************************

在Putty中执行insert_fields.sql后执行sh XX_OBJECT.sh我在输出中得到序列,如:

29
30
31
32
34

不知道为什么序列被无处触发

1 个答案:

答案 0 :(得分:1)

在您没有正确退出sql脚本之前,我已经看到了类似的内容。我相信它们只是从sqlplus输出的行号。您最有可能想要确保在脚本末尾有一个正确的退出语句,如下所示:

exit
/