Hello if you can help then please do so - else just ignore the mail and move on. No need to post rude replies or suggesstions to go and read the manual, which are unhelpful.
I have a shell script which collects the tablsepace information. If I run the SQL it work perfectly fine. However when I put in a script to run and mail the spool file at the end - nothing happens. It just drops back to the prompt. No file is generated and therefore no mail is sent. Can someone with better unix skills than myself have a quick glance and
make some suggesstions as to what I can do next or what I am doing wrong.
Many thanks
here is the script >>
#!/usr/bin/ksh
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=.:/usr/bin:/export/home/oracle/bin:/u01/app/oracle/product/10.2.0/db_1/bin:/usr/sbin:/usr/bin:/bin:/usr/local/bin:/usr/sfw/bin
export ORACLE_SID=smtprd1
export HOME=/u01/app/oracle/admin/dba/log
cd $HOME
if [[ $count -gt 0 ]];then
sqlplus / as sysdba << EOF
SET FEEDBACK OFF
SET LINESIZE 300
COLUMN alert_text FORMAT a80
clear breaks
clear computes
clear columns
set pagesize 50
set linesize 120
set heading on
column tablespace_name heading 'Tablespace' justify left format a20 truncated
column tbsize heading 'Size|(Mb) ' justify left format 9,999,999.99
column tbused heading 'Used|(Mb) ' justify right format 9,999,999.99
column tbfree heading 'Free|(Mb) ' justify right format 9,999,999.99
column tbusedpct heading 'Used % ' justify left format a8
column tbfreepct heading 'Free % ' justify left format a8
break on report
compute sum label 'Totals:' of tbsize tbused tbfree on report
select t.tablespace_name, round(a.bytes,2) tbsize,
nvl(round(c.bytes,2),'0') tbfree,
nvl(round(b.bytes,2),'0') tbused,
to_char(round(100 * (nvl(b.bytes,0)/nvl(a.bytes,1)),2)) || '%' tbusedpct,
to_char(round(100 * (nvl(c.bytes,0)/nvl(a.bytes,1)),2)) || '%' tbfreepct
from dba_tablespaces t,
(select tablespace_name, round(sum(bytes)/1024/1024,2) bytes
from dba_data_files
group by tablespace_name
union
select tablespace_name, round(sum(bytes)/1024/1024,2) bytes
from dba_temp_files
group by tablespace_name ) a,
(select e.tablespace_name, round(sum(e.bytes)/1024/1024,2) bytes
from dba_segments e
group by e.tablespace_name
union
select tablespace_name, sum(max_size) bytes
from v$sort_segment
group by tablespace_name) b,
(select f.tablespace_name, round(sum(f.bytes)/1024/1024,2) bytes
from dba_free_space f
group by f.tablespace_name
union
select tmp.tablespace_name, (sum(bytes/1024/1024) - sum(max_size)) bytes
from dba_temp_files tmp, v$sort_segment sort
where tmp.tablespace_name = sort.tablespace_name
group by tmp.tablespace_name) c
where
t.tablespace_name = a.tablespace_name (+)
and t.tablespace_name = b.tablespace_name (+)
and t.tablespace_name = c.tablespace_name (+)
order by t.tablespace_name
/
SPOOL /tmp/tablespace_report.txt
/
SPOOL OFF;
EXIT;
EOF;
mailx -s "Tablespace for $ORACLE_SID"
name@company.com </tmp/tablespace_report.txt
<EOF
$(cat ${/tmp}/tablespace_report.txt)
EOF
fi