自己写的一个menu脚本

#!/bin/sh
#This is a main menu scripts
#*********************************
#define the menu functions
#*********************************
menu () {
  cat <&lt;EOF
             ***********************************
             1) QQ  | 2) netscape | 3) webserver
             ***********************************
             4) EXIT
EOF
#**********************************
#This is a main programm
#**********************************
while true
do
echo -n "Please choice [1-4]:"
read choice
case $choice in
   1) clear
       QQ_menu       #caling the QQ_menu functions
      ;;
   2) clear
       netscape      #calling the netscape functions
      ;;
   3) clear
       httpd_menu    #calling the httpd_menu functions
       ;;
   *) exit
      ;;
esac
done
}
#define the QQ functions
QQ_menu () {
curdate=`date "+%Y-%m-%d %T"`
cat &lt;&lt;EOF
                     DATE: $curdate
                    ************************
                    1) start_qq | 2) kill_qq
                    ************************
                    3) EXIT
EOF
curr_pid=$$
while true
  do
echo -n "Please choice [1-3]:"
read choice
case $choice in
       1) clear
          /software/LumaQQ/lumaqq &
           QQ_menu
           ;;
       2)  clear
      ps -ef|grep lumaqq|grep -v grep|awk '{print $2}'>/tmp/${curr_pid}.txt
             for pid in `cat /tmp/${curr_pid}.txt`
                     do
                          kill  $pid
                           echo "Tt's Killed!"
                     rm -f /tmp/${curr_pid}.txt
                          done
           QQ_menu       #calling the QQ_menu functions
           ;;
          3) clear
             menu        #calling the menu functions
             ;;
esac
done
}
#################
#define the netscape functions
netscape () {
     cat &lt;&lt;EOF
                **********************************
                1) start netscape 2) stop netscape
                **********************************
                3) EXIT
EOF
current_pid=$$
while true
  do
echo -n "Please choice [1-3]:"
read choice
case $choice in
  1) clear
     echo "Start the netscape......."
     /software/navigator/navigator &
     netscape
     ;;
   2) clear
      echo "Kill netscape......"
      ps -ef|grep navigator|grep -v grep|awk '{print $2}'|while read pid
        do
          kill  $pid
         done
    ps -ef|grep netscape|grep -v grep|awk '{print $2}'|if [ $pid -eq ""]
then
echo "The netscape process was killed!"
fi
       netscape
        ;;
     3) clear
        menu
        ;;
esac
done
}
#***************************************
#This scripts control the httpd service
#define httpd_menu functions
httpd_menu () {
curdate=`date "+%Y-%m-%d %T"`
cat &lt;&lt;EOF
                 DATE: $curdate
              *********************************************
              1) start httpd  2) show_process 3) stop httpd
              *********************************************
              4) EXIT
EOF
#define httpd_menu functions finish!
#define the start_httpd functions
start_httpd () {
echo "Start the web server,please waiting..."
/usr/sbin/httpd &
}
#The start_httpd functions defined finish
#define show_procee functions
show_process () {
echo "Show the httpd process_id.."
ps -ef|grep httpd|grep -v grep|awk '{print $1,$2,$8}'
sleep 10
}
#define over
#define the kill_httpd functions
kill_httpd () {
echo "Stop the web server,please waiting...."
ps -ef|grep httpd|grep -v grep|awk '{print $2}'|while read pid
do
echo "$pid"
kill $pid
done
echo "The web server was stopped!"
}
#define the kill_httpd functions finish!
#main scripts
while true
do
echo -n "Please choice [1-4]:"
read choice
case $choice in
   1) clear
   start_httpd
   echo "It's started....."
   httpd_menu
   ;;
   2) clear
   show_process
   httpd_menu
   ;;
   3) clear
   kill_httpd
   httpd_menu
   ;;
   4) clear
      menu
   ;;
esac
done
}
#This is main programm
menu                             #Calling the menu functions
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值