Error while executing the shell script

Hi Gurus,

The following script fails with the error 'command not found' while trying to execute. As the error indicates, the script fails at ROW#30 where the EOF is defined for SQL statement.

It appears that the script is trying execute the lines in the SQL output written to ta spool file. However in the end, script performs the tasks as specified. But i need to have a clean exit after the execution so that I can promote it to production environment.

#!/bin/sh
. ${HOME}/.bash_profile
. ${scripts}/.dr_env.cfg
logfile=${logs}/update_ldr_conn.log
export TmpFile=$scripts/ctrl/temp.$$
printf "\n==========================================================================" >> $logfile
printf "           `date` : Loader Connection update script \n" >> $logfile
printf "\n==========================================================================" >> $logfile
`sqlplus -s $SQL_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
SPOOL ${TmpFile}
SELECT CN.OBJECT_NAME,AT.ATTR_VALUE FROM OPB_CNX CN, OPB_CNX_ATTR AT WHERE CN.OBJECT_ID=AT.OBJECT_ID AND AT.ATTR_VALUE = '${TD_PRD_DB}';
SPOOL OFF
SET SERVEROUT OFF
exit
EOF`
echo $RC
RC=$?
if [ $RC -eq 0 ] ; then
        printf "\nSuccessfully selected the rows." >> $logfile
  else
        printf "\nError! while trying to run the select query." >> $logfile
        exit 1
 fi
if [[ -s ${TmpFile} ]] ; then

printf "\nThe following TD Loader connections will be updated with DR Server information." >> $logfile
cat ${TmpFile} >> $logfile

`sqlplus -s $SQL_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
UPDATE OPB_CNX_ATTR SET ATTR_VALUE='${TD_DR_DB}' WHERE ATTR_VALUE='${TD_PRD_DB}';
COMMIT;
SET SERVEROUT OFF
exit
EOF`
echo $RC
RC=$?
if [ $RC -eq 0 ]
then
        printf "\nSuccessfully updated the TD DR Database name in the Loader connections." >> $logfile
        exit 0

ERROR

./ldr_conn_update.sh: line 30: TD_Tpump_Insert: command not found

0

Are you sure you posted the right script? Line 30 is NOT the EOF, and the command TD_Tpump_Insert causing the err msg is not found anywhere in the script.
And, remove the space before the EOF!

also you may want to swap these 2 lines:

echo $RC
RC=$?

Hi RudiC,

As mentioned earlier, script is throwing an error from the first line of output from the SQL spool file, which is
TD_Tpump_InsertAs you suggested, I have removed the space before EOF and tried it, but still it fails with the same error.

you don't need 'active function' for sqlplus - remove the ` from `sqlplus -s $SQL_LOGON and from EOF`

1 Like

Just for clarity, here I am pasting the output of the spoolfile created by the SQL statement.

inform@pocinf09:/app/prod/informat/Scripts/ctrl:#cat temp.21791

TD_Tpump_Insert
TDEDW

TD_TRUNCATE_FASTLOAD
TDEDW

TD_Tpump_Upsert
TDEDW

TD_Tpump_Update
TDEDW

TD_Tpump_Delete

TDEDW

TD_Mload_Upsert
TDEDW

TD_Mload_Update
TDEDW

TD_MLOAD_UPSERT_DYNAMIC
TDEDW

TD_MLOAD_INSERT_DYNAMIC
TDEDW


SIEBEL_TD_OLAP_TPUMP_INSERT_DYNAMIC
TDEDW

SIEBEL_TERADATA_MLOAD_INSERT_DYNAMIC
TDEDW

see suggestions above

removing the active function as you suggested did the trick. Thanks much!