rajeshtektips
Programmer
Hi ,
I am invoking awk in shell script and its giving the below error..
syntax error The source line is 7.
The error context is
$ORACLE_HOME/bin/sqlldr >>> safety/safety@ <<<
awk: The statement cannot be correctly parsed.
The source line is 7.
syntax error The source line is 12.
Please find below the code
#!/bin/sh
# Title load_compman.sh
# Purpose To load safety data into the database
# DB/Schema Metrics/safety
# Dependencies Sqlloader controlfile : load_data.ctl,
# Database Procedure : wc_dbload
# ==========================================================
#
#--- Set the environment
ORACLE_HOME=/u00/app/oracle/product/9.2.0; export ORACLE_HOME
ORACLE_SID=dwhdev; export ORACLE_SID
TNS_ADMIN=/etc; export TNS_ADMIN
CUR_DT=`date +"%m%d%Y%H%M"`; export CUR_DT
COMPMAN_TOP=/home/safety/safety/development; export COMPMAN_TOP
SCRIPT_DIR=$COMPMAN_TOP/scripts; export SCRIPT_DIR
DATA_DIR=$COMPMAN_TOP/incoming; export DATA_DIR
DATA_DIR_MAJ=$COMPMAN_TOP/incoming_majestic; export DATA_DIR_MAJ
LOG_DIR=$COMPMAN_TOP/log; export LOG_DIR
BACKUP_DIR=$COMPMAN_TOP/backup; export BACKUP_DIR
#--------------------------------------------------------------
#--- Check for the presence of Signal files and process
if test -f $DATA_DIR/*.dat
then
cat $DATA_DIR/*.dat > $DATA_DIR/incoming.out
$ORACLE_HOME/bin/sqlldr safety/safety@dwhdev.world \
control=$SCRIPT_DIR/load_config_compman.ctl \
bad=$SCRIPT_DIR/incoming.bad \
log=$LOG_DIR/incoming.log
mv $DATA_DIR/*.dat $BACKUP_DIR
cp $DATA_DIR/incoming.out $BACKUP_DIR/incoming$CUR_DT.out
rm $DATA_DIR/incoming.out
#--- Load data to Claim table
$ORACLE_HOME/bin/sqlplus safety/safety@dwhdev.world <<EOF
-- Should we spool the log or output ?
execute wc_dbload ('ALL');
-- spool off
EOF
else
echo '****** No records from the Signal customer ******' >> $LOG_DIR/incoming.log
fi
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming.log
cat $LOG_DIR/incoming.log > $LOG_DIR/inbox_status
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status
cp $LOG_DIR/inbox_status $BACKUP_DIR/inbox_status$CUR_DT
cp $LOG_DIR/incoming.log $BACKUP_DIR/incoming_$CUR_DT.log
rm $LOG_DIR/inbox_status
rm $LOG_DIR/incoming.log
#--- Check for the presence of Majestic files and process
if test -f $DATA_DIR_MAJ/*.TXT
then
cat $DATA_DIR_MAJ/*.* > $DATA_DIR_MAJ/incoming_maj.out
awk '
{ prov = $1;FS = "|"
if (prov == 'MAJESTIC')
{
$ORACLE_HOME/bin/sqlldr safety/safety@dwhdev.world \
control=$SCRIPT_DIR/load_config_compman.ctl \
bad=$SCRIPT_DIR/incoming_maj.bad \
log=$LOG_DIR/incoming_maj.log
mv $DATA_DIR_MAJ/*.dat $BACKUP_DIR
cp $DATA_DIR_MAJ/incoming_maj.out $BACKUP_DIR/incoming_maj$CUR_DT.out
rm $DATA_DIR_MAJ/incoming_maj.out
#--- Load data to Claim table
$ORACLE_HOME/bin/sqlplus safety/safety@dwhdev.world <<EOF
-- Should we spool the log or output ?
execute wc_dbload ('ALL');
-- spool off
EOF
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming_maj.log
cat $LOG_DIR/incoming_maj.log > $LOG_DIR/inbox_status_maj
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status_maj
cp $LOG_DIR/inbox_status_maj $BACKUP_DIR/inbox_status_maj$CUR_DT
cp $LOG_DIR/incoming_maj.log $BACKUP_DIR/incoming_maj_$CUR_DT.log
rm $LOG_DIR/inbox_status_maj
rm $LOG_DIR/incoming_maj.log
exit }
else
{
$ORACLE_HOME/bin/sqlldr safety/safety@dwhdev.world \
control=$SCRIPT_DIR/load_majestic.ctl skip 1\
bad=$SCRIPT_DIR/incoming_maj.bad \
log=$LOG_DIR/incoming_maj.log
mv $DATA_DIR_MAJ/*.dat $BACKUP_DIR
cp $DATA_DIR_MAJ/incoming_maj.out $BACKUP_DIR/incoming_maj$CUR_DT.out
rm $DATA_DIR_MAJ/incoming_maj.out
#--- Load data to Claim table
$ORACLE_HOME/bin/sqlplus safety/safety@dwhdev.world <<EOF
-- Should we spool the log or output ?
execute wc_dbload_new ('ALL');
-- spool off
EOF
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming_maj.log
cat $LOG_DIR/incoming_maj.log > $LOG_DIR/inbox_status_maj
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status_maj
cp $LOG_DIR/inbox_status_maj $BACKUP_DIR/inbox_status_maj$CUR_DT
cp $LOG_DIR/incoming_maj.log $BACKUP_DIR/incoming_maj_$CUR_DT.log
rm $LOG_DIR/inbox_status_maj
rm $LOG_DIR/incoming_maj.log
exit }
}' incoming_maj.out
#--- Load data to Claim table
else
echo '****** No records from the Majestic customer ******' >> $LOG_DIR/incoming_maj.log
fi
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming_maj.log
cat $LOG_DIR/incoming_maj.log > $LOG_DIR/inbox_status_maj
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status_maj
cp $LOG_DIR/inbox_status_maj $BACKUP_DIR/inbox_status_maj$CUR_DT
cp $LOG_DIR/incoming_maj.log $BACKUP_DIR/incoming_maj_$CUR_DT.log
rm $LOG_DIR/inbox_status_maj
rm $LOG_DIR/incoming_maj.log
exit
I am invoking awk in shell script and its giving the below error..
syntax error The source line is 7.
The error context is
$ORACLE_HOME/bin/sqlldr >>> safety/safety@ <<<
awk: The statement cannot be correctly parsed.
The source line is 7.
syntax error The source line is 12.
Please find below the code
#!/bin/sh
# Title load_compman.sh
# Purpose To load safety data into the database
# DB/Schema Metrics/safety
# Dependencies Sqlloader controlfile : load_data.ctl,
# Database Procedure : wc_dbload
# ==========================================================
#
#--- Set the environment
ORACLE_HOME=/u00/app/oracle/product/9.2.0; export ORACLE_HOME
ORACLE_SID=dwhdev; export ORACLE_SID
TNS_ADMIN=/etc; export TNS_ADMIN
CUR_DT=`date +"%m%d%Y%H%M"`; export CUR_DT
COMPMAN_TOP=/home/safety/safety/development; export COMPMAN_TOP
SCRIPT_DIR=$COMPMAN_TOP/scripts; export SCRIPT_DIR
DATA_DIR=$COMPMAN_TOP/incoming; export DATA_DIR
DATA_DIR_MAJ=$COMPMAN_TOP/incoming_majestic; export DATA_DIR_MAJ
LOG_DIR=$COMPMAN_TOP/log; export LOG_DIR
BACKUP_DIR=$COMPMAN_TOP/backup; export BACKUP_DIR
#--------------------------------------------------------------
#--- Check for the presence of Signal files and process
if test -f $DATA_DIR/*.dat
then
cat $DATA_DIR/*.dat > $DATA_DIR/incoming.out
$ORACLE_HOME/bin/sqlldr safety/safety@dwhdev.world \
control=$SCRIPT_DIR/load_config_compman.ctl \
bad=$SCRIPT_DIR/incoming.bad \
log=$LOG_DIR/incoming.log
mv $DATA_DIR/*.dat $BACKUP_DIR
cp $DATA_DIR/incoming.out $BACKUP_DIR/incoming$CUR_DT.out
rm $DATA_DIR/incoming.out
#--- Load data to Claim table
$ORACLE_HOME/bin/sqlplus safety/safety@dwhdev.world <<EOF
-- Should we spool the log or output ?
execute wc_dbload ('ALL');
-- spool off
EOF
else
echo '****** No records from the Signal customer ******' >> $LOG_DIR/incoming.log
fi
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming.log
cat $LOG_DIR/incoming.log > $LOG_DIR/inbox_status
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status
cp $LOG_DIR/inbox_status $BACKUP_DIR/inbox_status$CUR_DT
cp $LOG_DIR/incoming.log $BACKUP_DIR/incoming_$CUR_DT.log
rm $LOG_DIR/inbox_status
rm $LOG_DIR/incoming.log
#--- Check for the presence of Majestic files and process
if test -f $DATA_DIR_MAJ/*.TXT
then
cat $DATA_DIR_MAJ/*.* > $DATA_DIR_MAJ/incoming_maj.out
awk '
{ prov = $1;FS = "|"
if (prov == 'MAJESTIC')
{
$ORACLE_HOME/bin/sqlldr safety/safety@dwhdev.world \
control=$SCRIPT_DIR/load_config_compman.ctl \
bad=$SCRIPT_DIR/incoming_maj.bad \
log=$LOG_DIR/incoming_maj.log
mv $DATA_DIR_MAJ/*.dat $BACKUP_DIR
cp $DATA_DIR_MAJ/incoming_maj.out $BACKUP_DIR/incoming_maj$CUR_DT.out
rm $DATA_DIR_MAJ/incoming_maj.out
#--- Load data to Claim table
$ORACLE_HOME/bin/sqlplus safety/safety@dwhdev.world <<EOF
-- Should we spool the log or output ?
execute wc_dbload ('ALL');
-- spool off
EOF
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming_maj.log
cat $LOG_DIR/incoming_maj.log > $LOG_DIR/inbox_status_maj
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status_maj
cp $LOG_DIR/inbox_status_maj $BACKUP_DIR/inbox_status_maj$CUR_DT
cp $LOG_DIR/incoming_maj.log $BACKUP_DIR/incoming_maj_$CUR_DT.log
rm $LOG_DIR/inbox_status_maj
rm $LOG_DIR/incoming_maj.log
exit }
else
{
$ORACLE_HOME/bin/sqlldr safety/safety@dwhdev.world \
control=$SCRIPT_DIR/load_majestic.ctl skip 1\
bad=$SCRIPT_DIR/incoming_maj.bad \
log=$LOG_DIR/incoming_maj.log
mv $DATA_DIR_MAJ/*.dat $BACKUP_DIR
cp $DATA_DIR_MAJ/incoming_maj.out $BACKUP_DIR/incoming_maj$CUR_DT.out
rm $DATA_DIR_MAJ/incoming_maj.out
#--- Load data to Claim table
$ORACLE_HOME/bin/sqlplus safety/safety@dwhdev.world <<EOF
-- Should we spool the log or output ?
execute wc_dbload_new ('ALL');
-- spool off
EOF
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming_maj.log
cat $LOG_DIR/incoming_maj.log > $LOG_DIR/inbox_status_maj
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status_maj
cp $LOG_DIR/inbox_status_maj $BACKUP_DIR/inbox_status_maj$CUR_DT
cp $LOG_DIR/incoming_maj.log $BACKUP_DIR/incoming_maj_$CUR_DT.log
rm $LOG_DIR/inbox_status_maj
rm $LOG_DIR/incoming_maj.log
exit }
}' incoming_maj.out
#--- Load data to Claim table
else
echo '****** No records from the Majestic customer ******' >> $LOG_DIR/incoming_maj.log
fi
$ORACLE_HOME/bin/sqlplus -s safety/safety@dwhdev.world @$SCRIPT_DIR/verify_load >> $LOG_DIR/incoming_maj.log
cat $LOG_DIR/incoming_maj.log > $LOG_DIR/inbox_status_maj
mailx -m -s "Safety data process status for `date`" xxxx@xxx.com < $LOG_DIR/inbox_status_maj
cp $LOG_DIR/inbox_status_maj $BACKUP_DIR/inbox_status_maj$CUR_DT
cp $LOG_DIR/incoming_maj.log $BACKUP_DIR/incoming_maj_$CUR_DT.log
rm $LOG_DIR/inbox_status_maj
rm $LOG_DIR/incoming_maj.log
exit