#!/bin/bash
read -p "输入你想执行的操作(run|kill):" exec
read -p "输入对应的进程(server|web|all):" process
function run_process() {
case ${1} in
all)
echo '启动所有进程'
;;
server)
echo '只启动server'
;;
web)
echo '只启动web'
;;
*)
echo "Usage: $0 {server|web|all}"
;;
esac
}
function kill_process() {
case ${1} in
all)
echo '杀掉所有进程'
;;
server)
echo '杀掉server的进程'
;;
web)
echo '杀掉web的进程'
;;
*)
echo "Usage: $0 {server|web|all}"
;;
esac
}
case $exec in
run)
run_process $process
;;
kill)
kill_process $process
;;
*)
echo "Usage: $0 {run|kill}"
;;
esac
echo '结束'
标签:web,shell,run,read,echo,键盘,process,kill,server
From: https://blog.51cto.com/u_14346538/7231531