0

I am trying to run my script which checks for a file existence and validates its records. If validation is successful it uploads the input file to database.`

While executing the script ,it loads the file to table but displays below errors and successful completion part is not echoed.Below is my execution output.

./GIC.sh[3]: RETAIL_PATH:  not found

./GIC.sh[4]: DB_LOGIN: not found

./GIC.sh[10]: INPUTFILE: not found

./GIC.sh[14]: test: argument expected

./GIC.sh[20]: test: argument expected

Thu Jul 8 07:00:53 2021 run SQL*LOADER for

SQL*Loader: Release 18.0.0.0.0 - Production on Thu Jul 8 07:00:53 2021 Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.

Path used: Conventional Commit point reached - logical record count 11

Table GIC_TERMR_STG: 9 Rows successfully loaded.

My code is as below:

#!/bin/sh

RETAIL_PATH =/central DB_LOGIN =/@RETAIL_CENTRAL

CTLFILE=$RETAIL_PATH/sld/GIC_termr.ctl LOGFILE=$RETAIL_PATH/log/sld/GIC_termr.log BADFILE=$RETAIL_PATH/log/sld/GIC_termr.bad

INPUTFILE = $RETAIL_PATH/bin/sample.txt SUPPORT_EMAIL="valarmathi.pauldurai@bmo.com"

if [ ! -f $INPUTFILE ]; then pecho " Cannot find the Input file :$INPUTFILE " fi

#Inputfile check

if [ ! -f $INPUTFILE ]; then pecho "can't find SQLLoader Input file $INPUTFILE" mailx -s "cannot find input file $INPUTFILE" $SUPPORT_EMAIL exit 0 fi pecho "run SQLLOADER for $INPUTFILE" sqlldr $DB_LOGIN control=$CTLFILE log=$LOGFILE bad=$BADFILE

tmp_var1=$? if [ $tmp_var1 -eq 0 ]; then pecho "Sucessful completion" else

pecho "SQL*Loader log file in $SLDLOG"

echo "Please refer to $RETAIL_PATH/log/sld/${BADFILE}.bad and ${LOGFILE}." | mailx -s "subj XXX" "${SUPPORT_EMAIL}"

fi

exit 0

Flower
  • 21
  • 4
    Please take the time to read a basic shell scripting tutorial so you know what the syntax is. You can't have spaces around the = in variable assignments. – terdon Jul 08 '21 at 11:30
  • 3
    Paste your script into https://shellcheck.net and fix obvious errors first, like spaces between variable names and the equals sign. – Panki Jul 08 '21 at 11:30

0 Answers0