Shell Menu Script

Source: Internet
Author: User

#!/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," "a

Expr $a + 0 &>/dev/null

If [$?-eq 0]&& ($a <=4); then


echo "Please input a number{1|2|3|4}" && break


Else

echo "You input no not number,please lose!"

echo "Please input a number{1|2|3|4}" && continue

Fi

Done

If [$a-eq 1];then

User1

Read-p "Please input your want look MySQL function sn!:" A1

Expr $a 1 + 1 &>/dev/null

If [$?-eq 0];then

If [$a 1-eq 1]&&[-n $a 1];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 $ "\ t" $ "t" $ "\ T" $4 "\ T" $ "\ T" $ "\" $6} '

echo "MySQL process open!"

Else

echo "MySQL process no open!"

Fi

elif [$a 1-eq 2]&&[-n $a 1];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 [$a 1-eq 3]&&[-n $a 1];then

echo "Install Apache 5.3.3"

echo "No install MySQL function!"

elif [$a 1-eq 4]&&[-n $a 1];then

echo "quit MySQL function interface!"

Exit

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi

#11

elif [$a-eq 2];then

#2

User2

Read-p "Please input your want look Samba function sn!:" A2

Expr $a 2 + 1 &>/dev/null

If [$?-eq 0];then

If [$a 2-eq 1]&&[-n $a 2];then

b1=$ (ps-ef| grep "SMB" | grep-v "grep" |wc-l)

b2=$ (ps-ef| grep "NMB" | grep-v "grep" |wc-l)

Expr $B 1 + $B 2 + 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 [$a 2-eq 2]&&[-n $a 2];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 $BB 1 + $BB 2 + $BB 3 + $BB 4 + 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 [$a 2-eq 3]&&[-N $a 2];then

echo "Install Samba 5.3.3"

echo "No install samba function!"

elif [$a 2-eq 4]&&[-n $a 2];then

echo "Quit Samba function interface!"

Exit

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi

#22

elif [$a-eq 3];then

#3

User3

Read-p "Please input your want look postfix function sn!:" A3

Expr $a 3 + 1 &>/dev/null

If [$?-eq 0];then

If [$a 3-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 [$a 3-eq 2];then

cc=$ (Netstat-tlun | grep | grep "TCP" |wc-l)

Expr $CC + 0 &>/dev/null

If [$?-eq 0];then

Netstat-tlun | grep "25" | grep "TCP"

echo "Postfix Port open!"

Else

echo "Postfix Port no open!"

Fi

elif [$a 3-eq 3];then

echo "Install Postfix 5.3.3"

echo "No install postfix function!"

elif [$a 3-eq 4];then

echo "Quit Postfix function interface!"

Exit

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi

#33

elif [$a-eq 4];then

#4

echo "Quit function menu!"

Exit

#44

Else

echo "You entered are not {1|2|3|4} have quit!"

Fi


Shell Menu Script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.