Hello all,
I am running a script to generate a report and mail it to an email address.
When I am trying to validate whether the file is a 0 kb file, I am getting the below error.
Error: "Syntax error; unexpected end of file"
Any suggestions please?
Code:
#!/bin/sh
. $HOME/.bash_profile
sqlplus /@conn<<EOF
WHENEVER SQLERROR EXIT 1 ROLLBACK
WHENEVER OSERROR EXIT 1 ROLLBACK
SET MARKUP HTML ON
SET PAGESIZE 50000
SET FEEDBACK OFF
@/home/usr/scripts/script.sql;
EOF
CDATE=$CDATE"`date +"%y%m%d"`.xls";
ODFILENAME="/home/usr/reports/ ";
ODFILENAME=$ODFILENAME"$CDATE";
if [ -s "$ODFILENAME" ]; then
BODY=$BODY"Please find the extract."
else
BODY=$BODY"Zero KB file."
fi
mailx < send email >
Script.sql:
col spoolname new_value spoolname;
select 'draftExtract'||to_char(sysdate, 'yymmdd')||'.xls' spoolname from dual;
spool /home/usr/MIReports/&spoolname;
Select * from schema.file1;
spool OFF;
col spoolname new_value spoolname;
select 'Extract2'||to_char(sysdate, 'yymmdd')||'.xls' spoolname from dual;
spool /home/usr/MIReports/&spoolname;
Select * from schema.file2;
spool OFF;
SET MARKUP HTML OFF;