设为首页 收藏本站
查看: 1019|回复: 0

shell菜单脚本

[复制链接]

尚未签到

发表于 2018-8-24 13:02:43 | 显示全部楼层 |阅读模式
  #!/bin/sh
  AA='\E[1;31m'
  BB='\E[1;32m'
  CC='\E[1;33m'
  DD='\E[1;34m'
  EE='\E[1;35m'
  FF='\E[1;36m'
  GG='\E[1;37m'
  RES='\E[0m'
  cat (){
  echo -e "${AA} ===================================== ${RES}"
  echo -e "${DD} ======== 1.mysql function look ====== ${RES}"
  echo -e "${FF} ======== 2.samba function look ====== ${RES}"
  echo -e "${CC} ======== 3.postfix function look ==== ${RES}"
  echo -e "${GG} ======== 4.or please exit     ======= ${RES}"
  echo -e "${EE} ===================================== ${RES}"
  }
  user1 (){
  echo -e "${AA} ===================================== ${RES}"
  echo -e "${BB} ======== 1.look mysql process ======= ${RES}"
  echo -e "${BB} ======== 2.look mysql port    ======= ${RES}"
  echo -e "${BB} ======== 3.install mysql      ======= ${RES}"
  echo -e "${BB} ======== 4.or please exit     ======= ${RES}"
  echo -e "${EE} ===================================== ${RES}"
  }
  user2 (){
  echo -e "${AA} ===================================== ${RES}"
  echo -e "${FF} ======== 1.look samba process ======= ${RES}"
  echo -e "${FF} ======== 2.look mysql port    ======= ${RES}"
  echo -e "${FF} ======== 3.install samba      ======= ${RES}"
  echo -e "${FF} ======== 4.or please exit     ======= ${RES}"
  echo -e "${EE} ===================================== ${RES}"
  }
  user3 (){
  echo -e "${AA} ===================================== ${RES}"
  echo -e "${CC} ======== 1.look postfix process ===== ${RES}"
  echo -e "${CC} ======== 2.look postfix port    ===== ${RES}"
  echo -e "${CC} ======== 3.install samba        ===== ${RES}"
  echo -e "${GG} ======== 4.or please exit       ===== ${RES}"
  echo -e "${EE} ===================================== ${RES}"
  }
  cat
  while true
  do
  read -p "please input look function's number:" a
  expr $a + 0 &>/dev/null
  if [ $? -eq 0 ]&&(($a/dev/null
  if [ $? -eq 0 ];then
  if [ $a1 -eq 1  ]&&[ -n $a1 ];then
  A=$(ps -ef | grep "mysql" | grep -v "root" |wc -l)
  expr $A + 0 &>/dev/null
  if [ $? -eq 0 ];then
  /bin/ps -ef|grep "mysql" | grep -v "root" |awk '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6}'
  echo "mysql process open!"
  else
  echo "mysql process no open!"
  fi
  elif [ $a1 -eq 2  ]&&[ -n $a1 ];then
  AA=$(netstat -tlun | grep "3306" |wc -l)
  expr $AA + 0 &>/dev/null
  if [ $? -eq 0 ];then
  /bin/netstat -tlun | grep "3306"
  echo "mysql 3306 port open!"
  else
  echo "mysql 3306 port no open!"
  fi
  elif [  $a1 -eq 3 ]&&[ -n $a1 ];then
  echo "install apache 5.3.3"
  echo "no install mysql function!"
  elif [  $a1 -eq 4 ]&&[ -n $a1 ];then
  echo "quit mysql function interface!"
  exit
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi
  #11
  elif [ $a -eq 2 ];then
  #2
  user2
  read -p "please input you want look samba function SN!:" a2
  expr $a2 + 1 &>/dev/null
  if [ $? -eq 0 ];then
  if [ $a2 -eq 1  ]&&[ -n $a2 ];then
  B1=$(ps -ef| grep "smb"| grep -v "grep"|wc -l)
  B2=$(ps -ef| grep "nmb"| grep -v "grep"|wc -l)
  expr $B1 + $B2 + 0 &>/dev/null
  if [ $? -eq 0 ];then
  /bin/ps -ef| grep "smb"| grep -v "grep"
  /bin/ps -ef| grep "nmb"| grep -v "grep"
  echo "samba process open!"
  else
  echo "samba process no open!"
  fi
  elif [ $a2 -eq 2  ]&&[ -n $a2 ];then
  BB1=$(netstat -tlun | grep "445"|grep "0.0.0.0"|wc -l)
  BB2=$(netstat -tlun | grep "139"|grep "0.0.0.0"|wc -l)
  BB3=$(netstat -tlun | grep "138"|grep "0.0.0.0"|wc -l)
  BB4=$(netstat -tlun | grep "137"|grep "0.0.0.0"|wc -l)
  expr $BB1 + $BB2 + $BB3 + $BB4 + 0 &>/dev/null
  if [ $? -eq 0 ];then
  netstat -tlun | grep "445"|grep "0.0.0.0"
  netstat -tlun | grep "139"|grep "0.0.0.0"
  netstat -tlun | grep "138"|grep "0.0.0.0"
  netstat -tlun | grep "137"|grep "0.0.0.0"
  echo "samba "445" "139" "138" "137" port open!"
  else
  echo "samba "445" "139" "138" "137" port no open!"
  fi
  elif [  $a2 -eq 3 ]&&[ -n $a2 ];then
  echo "install samba 5.3.3"
  echo "no install samba function!"
  elif [  $a2 -eq 4 ]&&[ -n $a2 ];then
  echo "quit samba function interface!"
  exit
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi
  #22
  elif [ $a -eq 3 ];then
  #3
  user3
  read -p "please input you want look postfix function SN!:" a3
  expr $a3 + 1 &>/dev/null
  if [ $? -eq 0 ];then
  if [ $a3 -eq 1  ];then
  C=$(ps -ef | grep postfix | grep -v "grep" |wc -l)
  expr $C + 0 &>/dev/null
  if [ $? -eq 0 ];then
  /bin/ps -ef | grep postfix | grep -v "grep"
  echo "postfix process open!"
  else
  echo "postfix process no open!"
  fi
  elif [ $a3 -eq 2  ];then
  CC=$(netstat -tlun | grep "25"| grep "tcp"|wc -l)
  expr $CC + 0 &>/dev/null
  if [ $? -eq 0 ];then
  netstat -tlun | grep "25"| grep "tcp"
  echo "postfix 25 port open!"
  else
  echo "postfix 25 port no open!"
  fi
  elif [  $a3 -eq 3 ];then
  echo "install postfix 5.3.3"
  echo "no install postfix function!"
  elif [  $a3 -eq 4 ];then
  echo "quit postfix function interface!"
  exit
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi
  #33
  elif [ $a -eq 4 ];then
  #4
  echo "quit function menu!"
  exit
  #44
  else
  echo "You entered is not {1|2|3|4} has quit!"
  fi


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-555998-1-1.html 上篇帖子: shell常用语法案例 下篇帖子: Shell流程控制
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表