Hi All,
I am new to Unix, I have written the following script in ksh and get a syntax error :wall:. I need some help to figure out the error and reason. The script below uses some variables from an environment file, also it executes a sql file. The sql file is correct and has no problems. I need some help in Identifying the syntactical error in the script. I have pasted the output after the script.
#!/bin/ksh
#*********************************************************************************
#DAMA202.ksh Notification When XX Not Processing
#*********************************************************************************
#
#*********************************************************************************
#source in AMR function library
. $HOME"/scripts/amrksh.lib"
startjob_amr $0
#*******************************************************************************
#*STEP0 Get file name for log file
#*******************************************************************************
startstep_amr STEP0
AMA202L11=$(amr_get_file_gen_name AMA202L1) #Log file
if (($? != 0))
then
ppllog "amr_get_file_gen_name failed"
exit 1
fi
#*******************************************************************************
#*STEP1 Run the check processing script in a loop. If the query finds no
#* processing, send an e-mail.
#*******************************************************************************
startstep_amr STEP1
lasttime_warn=0
integer time_count=0
while (($time_count < $DAMA202_TIME_COUNT))
do
WINDOW_OPEN=$(in_TNSP_maintenance_window)
if [[ "$WINDOW_OPEN" = "Y" ]]
then
ppllog "TNSP Batch Window is open-skipping-"$0
sleep ${DAMA202_SLEEP_TIME}
else
sqlplus $USER/$PASSWORD@$ORACLE_SID\
@${AMR_SCRIPTS_PATH}DAMA202.sql ${AMA202L11} ${DAMA202_SLEEP_TIME}
RC=$?
mv ${AMA202L11}.lst ${AMA202L11}
if (($? != 0))
then
ppllog "SQL file rename failed"
exit 10
fi
if (($RC != 0))
then
if (($RC == 1))
then
if (($lasttime_warn == 0))
then
cat ${AMA202L11} | mailx -s "DCSI is not processing" ${DAMA202_EMAIL}
else
cat ${AMA202L11} | mailx -s "CRITICAL - DCSI is not processing" ${DAMA202_EMAIL_PAGE}
fi
else
ppllog "Check for DCSI not processing failed"
exit 11
fi
fi
lasttime_warn=$RC
fi
time_count=`expr $time_count + 1`
#*********************************************************************************
# #6 Exit script successfully if time is between 5:30 AM and 6 AM
#*********************************************************************************
NOW=$(date +%0H%0M)
if (( $NOW > 529 ))
then if (( $NOW < 601))
then endjob_amr $0
fi
fi
done
#*********************************************************************************
#Normal Termination
#*********************************************************************************
endjob_amr $0
Output:
--------------
Using default environment file
SQL*Plus: Release 9.2.0.8.0 - Production on Mon Aug 8 15:00:52 2011
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
JServer Release 9.2.0.8.0 - Production
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Producti
on
JServer Release 9.2.0.8.0 - Production
expr: Syntax error
SQL*Plus: Release 9.2.0.8.0 - Production on Mon Aug 8 15:01:53 2011
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
JServer Release 9.2.0.8.0 - Production
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Producti
on
JServer Release 9.2.0.8.0 - Production
0
./DAMA202.ksh[72]: 1: not found
SQL*Plus: Release 9.2.0.8.0 - Production on Mon Aug 8 15:02:54 2011
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
JServer Release 9.2.0.8.0 - Production
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Producti
on
JServer Release 9.2.0.8.0 - Production
0
./DAMA202.ksh[72]: 1: not found