日期:2014-05-16 浏览次数:20680 次
刚学shell 不久,写了一个脚本,主要用来启动和关闭mysql
#!/bin/bash #上一行为指定base 执行 #此脚本用于启动MyEcliplse function controlMyEclipse(){ echo "启动MyEcliplse" /opt/MyEclipse\ 8.5/myeclipse & } #此脚本用于启动firefox function controlFirefox(){ echo "启动firefox" firefox & } #此脚本用于启动mysql服务 function controlMySQL(){ echo "请选择 mySQL 服务执行的操作" select mySQLOperate in "start" "stop" "back"; do break done if [ "$mySQLOperate" = "start" ] then sudo /etc/init.d/mysql start #启动mySQL elif [ "$mySQLOperate" == "stop" ] then sudo /etc/init.d/mysql stop #停止mySQL elif [ "$mySQLOperate" == "back" ] then echo "返回上层操作." else echo "输入有误,请重新操作" fi } until [ "$operate" == "exit" ] #使脚本可以反复执行 do echo "请选择要进行的操作" select operate in "firefox" "myEclipse" "mySQL" "exit"; do break done case "$operate" in "firefox") controlFirefox ;; "myEclipse") controlMyEclipse ;; "mySQL") controlMySQL ;; "exit") echo "退出" ;; esac done exit