Hi ,
Following script is trying to email report after executing pl/sql procedure by passing commandline argument SALE_LOC while running the shell script.So far it is working fine.Issue is when by mistake commandline argument is not passed it should print error as "please give sale_loc as input parameter".How can i write this?
################################################################################
#####
SALE_LOC=$1
################################################################################
#####
# Variable Declarations
################################################################################
#####
. ~/env_vars
#JOB_NAME=" Report by Date"
REPORT_DIR=$INOUT
OUTPUT_FILE="report.txt"
REPORT_FILE="report.csv"
function email_report
{
ux2dos $REPORT_DIR/$OUTPUT_FILE > $REPORT_DIR/$REPORT_FILE
mailx -s "Report by Date " ${CONFIRMATION_EMAIL} <<- EOF
Please find the attached Report
~< ! uuencode $REPORT_DIR/$REPORT_FILE report.csv
EOF
}
# Execute the Oracle procedure.
#############################################################################
function execute_sql {
echo "Running SQL Script"
sqlplus -s ${ORACLE_CONNECT}<<- EOF
whenever sqlerror exit sql.sqlcode;
whenever oserror exit failure;
exec prddctn.Reports.report_allcntries($SALE_LOC);
EOF
return $?
}
#main
execute_sql
STATUS=$?
if [ $STATUS -eq 0 ]
then
echo "Mailing report to user"
email_report
fi
Thanks