08 December 2016

Shell script to send SQL query output in HTML format

#!/usr/bin/ksh
export ORACLE_BASE=/optware/oracle
ORACLE_HOME=/optware/oracle/11.2.0.4/db_1
export ORACLE_HOME
ORACLE_SID=PROD3
export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin
export PATH
ORAENV_ASK=NO

sqlplus /nolog <    connect sys/xxxxxxx as sysdba
SET MARKUP HTML ON PREFORMAT OFF ENTMAP ON -
HEAD "DB Sync Status Report -
-

-->" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='5'"
@/home/oracle/scripts/sync_status.sql
SPOOL /home/oracle/sync_status.html
/
SPOOL OFF
EXIT;
EOF

echo "Please find the attached report, showing the details on DB Sync Status." | mutt -a "/home/oracle/sync_status.html" -s "DB Sync Status" abc@xyz.com
rm /home/oracle/sync_status.html

No comments:

Post a Comment