我使用的语句是case 语句

case变量值in

模式1)

命令序列1

;;

模式2)

命令序列2

;;

……

*)

默认命令序列

esac

以下是脚本

#! /bin/bash
case "$1" in
start)
sqlplus -s /nolog > /dev/null <<eof
conn / as sysdba
startup
exit;
EOF
echo "Database openned."
;;

stop)
sqlplus -s /nolog > /dev/null <<eof
conn / as sysdba
shutdown immediate
exit
EOF
echo "Database stopped."
;;

restart)
sqlplus -s /nolog > /dev/null <<eof
conn / as sysdba
shutdown immediate
startup
exit
EOF
echo "Database restarted."
;;

status)
pmonstat=`ps -ef | grep ora_pmon | grep -v grep | wc -l`
if [ $pmonstat -gt 0 ]
then
dbstatus=`sqlplus -s /nolog <<eof
conn / as sysdba
set feedback off heading off pagesize 0
select status from v\\$instance;
exit
EOF`
echo "Database status:$dbstatus"
else
echo "Database not started."
fi
;;

*)
echo "----------------------------------------"
echo "Usage: start, stop, status, restart"
echo "----------------------------------------"
;;
esac

</eof
</eof
</eof
</eof