I have a unix menu setup to turn on/off index monitering on the DB. BUT the SQL output runs on the screen.
HOW can i prevent this from happening.
HOW can i prevent this from happening.
Code:
#!/bin/ksh
WORKDIR=/u1/home/oradba/
LOGS=/u1/home/oradba/logs/
LOGO=" INDEX MONITERING "
MONITORING=`cat /u1/home/oradba/logs/startmonitoring.txt | grep altered | wc -l`
Displaymenu () {
clear
echo `date`
echo
echo "\t\t\t\t" $LOGO
echo
echo "\tMonitoring=$MONITORING"
echo "\t\t"
echo "\tSelect Option:"
echo
echo "\t\t\t [1] Turn on Monitoring "
echo "\t\t\t [2] Turn off Monitoring "
echo "\t\t\t [3] Run Index Monitoring Report "
echo "\t\t\t [4] Exit Program "
echo
echo "Enter option then ENTER to continue: \c"
}
PressEnter () {
echo Press Enter
read x
}
# A function for each of the menu picks
turn_on_index()
{
echo " Executing Turn on Monitoring "
do_turn_on
PressEnter
}
turn_off_index()
{
echo "Executing Turn off Monitoring "
do_turn_off
PressEnter
}
index_report()
{
echo " Executing INDEX Report "
do_index_report
PressEnter
}
do_turn_on()
{
sqlplus -s mac/mac789 <<ENDOFSQL
@${WORKDIR}/startmonitoring.sql
exit;
ENDOFSQL
sqlplus -s mac/mac789 <<ENDOFSQL
@${LOGS}/startmonitoring.sql
exit;
ENDOFSQL
}
do_turn_off()
{
sqlplus -s mac/mac789 <<ENDOFSQL
@${WORKDIR}/stopmonitoring.sql
exit;
ENDOFSQL
sqlplus -s mac/mac789 <<ENDOFSQL
@${LOGS}/stopmonitoring.sql
exit;
ENDOFSQL
}
do_index_report()
{
sqlplus -s mac/mac789 <<ENDOFSQL
@${WORKDIR}/unused_index_rep.sql
exit;
ENDOFSQL
do_email
}
do_email()
{
echo "Emailing report now"
SUBJECT=" (Sun8) Unused MAC Index Report "
TO=oradba
(
cat $LOGS/unused_index_rep.txt
) | /usr/local/bin/mutt -a $LOGS/unused_index_rep.txt -s "$SUBJECT" $TO
}
while true
do
Displaymenu
read answer
case $answer in
1) turn_on_index ;;
2) turn_off_index ;;
3) index_report ;;
4) break ;;
esac
done
clear