Stolze the script is like this. As I said it works fine when I execute it alone.
#!/bin/ksh
. ~db2inst1/sqllib/db2profile
DIR=/export/home/db2inst1/utility
DATE='date'
db2 "connect to capprddb";
db2 "select substr('reorg table '||rtrim(t.tabschema)||'.'||t.tabname||' index '||rtrim(indschema)||'.'||indname||' use tempspace1;'
,1,125) from syscat.indexes i, syscat.tables t where i.tabname =t.tabname and t.type ='T' and (indextype='CLUS' or uniquerule='U' o
r uniquerule='P') order by t.tabschema, t.tabname" > $DIR/reorg.out;
sed -e '1,2d' $DIR/reorg.out > $DIR/reorg.log;
rm $DIR/reorg.out
db2 -tvf $DIR/reorg.log > $DIR/reorg_report.txt
cat $DIR/reorg_report.txt | mailx -s "Reorg Cap One UAT"
xxx@xxx.com
db2 connect reset;
Thank you all