无效行号

时间:2018-04-23 22:54:02

标签: linux bash shell

我有一个shell脚本,它是将数据从我们的Production oracle db迁移到TEST oracle db的一系列脚本的一部分。此脚本运行一个脚本,该脚本测试生产数据是否已更新(在ETL过程之后),然后查看是否已更新TEST。如果Prod尚未准备就绪,则不会发生任何动作。如果Prod准备好并且TEST没有更新,那么它将更新TEST。如果已更新TEST,则不会执行任何操作。这个脚本以前工作正常,但我今天必须添加一些sqlplus函数,这样做后,我收到一个错误(下面提供的错误),并且不再发送传出的电子邮件。

我从Windows计算机上传到stackoverflow;但是,这个脚本是在RHEL上用BASH 3.2进行的,我已经运行了:

:set ff=unix

但仍然收到相同的错误。错误中的行号始终比代码中的实际行数大1,因此我不确定发生了什么。任何帮助表示赞赏。

#!/bin/bash

####  Controller for REGION_FORECAST_UPCOMING_FY Migration Process (Prod to Test)


## Get DB Connection Strings
source /home2/olapdba/crons/db_cx.sh

## Check DB Statuses
## prod_test_status.sh will connect to:
##     PROD and see if the production data has been updated today.  The PROD data date is stored in variable PROD_DT and the conditional is stored in RETVAL
##     TEST and see if TEST has already been updated.   If so, then no need to run again.  If not, but PROD is updated, then update TEST (by migrating from PROD)
source /home2/olapdba/crons/region_forecast_upcoming_fy/prod_test_status.sh

### evaluate the return values:
###   retval = -1: TEST already completed
###   retval =  0: Production not updated; run later
###   retval =  1: Production updated, run migration process

if [ $retval -eq "1" ];
    then
        /home2/olapdba/crons/REGION_FORECAST_UPCOMING_FY/region_forecast_upcoming_fy_migration.csh && /home2/olapdba/crons/REGION_FORECAST_UPCOMING_FY/load_hist.sh
        ## Update REGION_FORECAST_UPCOMING_FY Logs in PROD and TEST for hadoop triggers
        sqlplus -s $DB_TEST <<sql
            execute ETLDBA.UPDATE_REGION_FORECAST_UPCOMING_FY_LOG;
            quit;
        sql


        sqlplus -s $DB_PROD <<sql
            execute ETLDBA.UPDATE_REGION_FORECAST_UPCOMING_FY_LOG;
            quit;
        sql
fi

if [ $retval -eq "-1" ];
    then
        msg="TEST already completed today."
elif [ $retval -eq "0" ];
    then
        msg="Production not updated today.  Run Later"
elif [ $retval -eq "1" ];
    then
        msg="Production Updated, TEST not updated.  Running process now."
fi

echo -e "RETVAL was $retval\nMSG= $msg\nCUR_DT = $CUR_DT\nPROD_DT = $PROD_DT\nTEST_DT = $TEST_DT" | mail -s "REGION_FORECAST_UPCOMING_FY Process Status $retval" "MY_EMAIL_ADDRESS@EMAIL>COM"

收到的错误是:

line 49: syntax error: unexpected end of file

0 个答案:

没有答案