0

I have a shell script that is part of a sequence of scripts that migrate data from our Production oracle db to the TEST oracle db. This script runs a script that tests to see if Production data is updated (after the ETL process) and then to see if TEST has already been updated. If Prod is not ready yet, then no action happens. If Prod is ready and TEST is not updated, then it will update TEST. If TEST is already updated, then no action happens. This script used to work fine but I had to add some sqlplus functions today and after doing so, I receive an error at the end (error provided below) and the outgoing email is no longer being sent.

I am uploading this to stackoverflow from a Windows computer; however, this script is staged in RHEL with BASH 3.2 and I've already ran:

:set ff=unix

but still receive the same error. The line number in the error is always 1 number greater than the count of actual lines in code so I'm not sure what is going on. Any help is appreciated.

#!/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"

The error received is:

line 49: syntax error: unexpected end of file
need_java
  • 127
  • 2
  • 4
  • 13

0 Answers0