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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。