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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。