shell菜单脚本

#!/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<=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 you want look mysql function SN!:" a1

expr $a1 + 1 &>/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

时间: 2024-08-14 15:39:43

shell菜单脚本的相关文章

(转)shell实现多级菜单脚本编写

shell实现多级菜单脚本编写 原文:https://www.yuanmas.com/info/2gOwBPvqyb.html 这篇文章主要介绍了Shell实现多级菜单系统安装脚本实例分享,本文脚本用多级菜单实现LAMP.LNMP安装展现效果,需要的朋友可以参考下: 提示:本脚本主要实现多级菜单效果,并没有安装LAMP.LNMP环境,如果要用在实际生成环境中部署LNMP.LAMP环境,只需要简单修改一下就可以了. 演示效果: 1.一级菜单 2.二级菜单 3.执行操作 脚本参考: 代码如下: #!

shell编程脚本语法

学习了两个月的Linux,记住了很多命令,知道了脚本的作用,也被脚本杀死了大概一半的脑细胞,现在脚本还不能熟练运用,感觉亏了.心疼我的脑细胞,痛恨脚本,但不得不说,脚本是一个好东西啊,用起来真的方便,但是写起来真的烧脑袋呦!下面来总结一下这周学习的脚本语法,哇,语法虽然不多也不难,但是结合起来熟练运用还有一定的难度,何况现在的脚本才几行,以后要写几行,心里没点数吗!废话少说,开始 跳过最基础的命令行堆积的脚本,总结一下让脚本更简洁实用的语法 首先,条件选择if语句登场 if语句用法:常见的单分支

怎么在命令模式下使用adb / 进入adb shell(脚本)

1.打开winows菜单,输入cmd命令,点击确定,进入命令模式下. 2.输入命令 D:(这里输入的D表示你的sdk存放的盘下) 然后回车输入cd 3.然后选择你sdk路径,复制路径. 4.鼠标点击cmd,选择编辑,选择粘贴 将复制的路径粘贴到 命令行 回车. 5.然后输入命令adb start-service 打开adb. 出现如图所示,表示adb服务开启成功,就可以使用adb命令了. 6.使用adb  shell 命令.--- 进入adb shell(脚本) 原文:http://jingya

shell之脚本实例

一 检查用户是否是root权限的方式:#!/bin/bashROOT_UID=0 # Root has $UID 0.E_WRONG_USER=65 # Not root? E_NOSUCHUSER=70SUCCESS=0 if [ "$UID" -ne "$ROOT_UID" ]then echo echo "Only root can run this script." echo exit $E_WRONG_USERelse echo ech

linux下的shell和脚本

1.各种Unix shell linux下的shell基本是从unix环境中的shell发展而来,贴一下wiki:其中我们常用的,可归类为Bourne Shell(/usr/bin/sh或/bin/sh).Bourne Again Shell(/bin/bash).C Shell(/usr/bin/csh).K Shell(/usr/bin/ksh).Shell for Root(/sbin/sh),等等 第一个Unix shell是由肯·汤普逊,仿效Multic上的shell所实现出来,称为s

【Telnet】使用Telnet协议连接到远程Shell执行脚本

介绍 本文介绍如何通过Telnet协议连接到远程Shell,执行脚本,并获取执行结果: 相关文章: <[Jsch]使用SSH协议连接到远程Shell执行脚本>http://www.cnblogs.com/ssslinppp/p/6244653.html 其他示例: http://commons.apache.org/proper/commons-net/examples/telnet/TelnetClientExample.java http://www.programcreek.com/ja

Linux shell 自启动脚本写法

# ********************************************************************** # Linux shell 自启动脚本写法 # 说明: # 我们在做系统的时候,写自启动脚本是常有的事,下面是一个样板分析. # # 2017-1-10 深圳 南山平山村 曾剑锋 # ********************************************************************** #!/bin/sh # 脚本

「笔记」「ubuntu」mint个人shell样式脚本

alias ll='ls -al' use_color=false # Set colorful PS1 only on colorful terminals.# dircolors --print-database uses its own built-in database# instead of using /etc/DIR_COLORS.  Try to use the external file# first to take advantage of user additions. 

linux 下shell 编写脚本

linux 下shell 编写脚本: 1.程序结构练习:编写一个脚本,给定一个正整数,计算出这个数所有位的数字之和. 例如:程序给定输入123,那么应该返回1+2+3=6. 2.程序结构练习:编写一个脚本,给定一个正整数,反序输出这个这个数. 例如:程序输入123,那么应该输出321. 3.Linux命令+shell编程:编写一个程序,实现定时文件备份的功能. 要求: 1.备份某个目录下的所有文件 2.对备份文件进行压缩 3.生成合理的日志文件 4.Shell下的gui(libnotify-bi