$ mail -s "$(echo -e "$Subject Tablespace Usage\nContent-Type: text/html;\n\n")" example@gmail.com < index.html
echo index.html | mail -s "$(echo -e "Tablespace Usage \nContent-Type: text/html")" example@gmail.com
$(echo -e "$Subject\nContent-Type: text/html;\n\n)"
Below is for SQLPLUS :-
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" @/usr/local/opt/oracle/oraadmin/ipag/monitor/long_run_session.sql > ${MAILMSGFILE}
pr -e -t ${MAILMSGFILE} | mailx -s "IDIS Long Running Queries on $HOST: $ORACLE_SID" ${MAILLIST}
$ mail -s "$(echo -e "$Subject Tablespace Usage \n Content-Type: text/html \n charset=utf-8")" example@gmail.com
$ echo "attachment" | mailx -s "Tablespace usage" -a index.html example@gmail.com
oracle@hostame : path/ $ cat try.sh
#!/bin/sh
command=`df -h `
echo "${command}" > index.html
oracle@hostname: path/$ sh try.sh oracle@hostname: path/ $ cat testmail.sh #!/bin/sh echo "email_to:" read email_to echo "email_from:" read email_from echo "Subject:" read subject echo "file_path" read filepath ( echo "To: ${email_to}" echo "From: ${email_from}" echo "Subject: ${subject}" echo "Mime-Version: 1.0" echo "Content-Type: text/html; charset='utf-8'" echo cat ${filepath} ) | sendmail -toracle@hostname: path/ $ sh testmail.sh email_to: user@sample.com email_from: oracle@hostname Subject: Space free file_path index.htm+++++++++++++++++++++++++++++++++++++++++++++++++++++++Sample Shell Script To send HTML report From SQL Queryhost:log/ $ cat test.sh #!/bin/sh echo "Enter SQL query:" read query sqlplus / as sysdba << EOF set markup HTML on; spool index.html; ${query}; spool off; set markup HTML off; exit; EOF echo "email_to:" read email_to echo "email_from:" read email_from echo "Subject:" read subject echo "file_path" read filepath ( echo "To: ${email_to}" echo "From: ${email_from}" echo "Subject: ${subject}" echo "Mime-Version: 1.0" echo "Content-Type: text/html; charset='utf-8'" echo echo "<body><style> th{background-color:gold;} table{border:2px solid blue;}</style></body>" echo cat ${filepath} ) | sendmail -t
No comments:
Post a Comment