shell 下简单菜单脚本
menu.sh 菜单界面脚本
#!/bin/bash
#menu.sh
function menu(){
cat << eof
#############################################
`echo -e "\033[32;40m menu \033[0m"`
#############################################
* 1)add a user
* 2)set password for user
* 3)delete a user
* 4)print disk space
* 5)print mem space
* 6)quit
* 7)return
#############################################
www.baibai.com `date +%Y-%m-%d`
#############################################
eof
}
index.sh 菜单功能脚本
#!/bin/bash #index.sh . menu.sh menu read -p "please input a option:" option case $option in 1)read -p "add a user:" name useradd $name if [ $? -eq 0 ];then str="$name is created sucessfully!" echo -e "\033[31;40m$str\033[0m" else str="$name is created unsucessfuly!" echo -e "\033[31;40m$str\033[0m" fi ;; 2)read -p "input a username:" name read -p "set pass for user:" pass echo $pass | passwd --stdin $name if [ $? -eq 0 ];then str="set passwd for $name sucessfully!" echo -e "\033[31;40m$str\033[0m" else str="set passwd for $name unsucessfully!" echo -e "\033[31;40m$str\033[0m" fi ;; 3)read -p "dalete a user:" name userdel -r $name if [ $? -eq 0 ];then str="delete $name sucess!" echo -e "\033[31;40m$str\033[0m" else str="delete $name unsucessfully!" echo -e "\033[31;40$str\033[0m" fi ;; 4)str=`free -m` echo -e "\033[33;40m$str\033[0m" ;; 5)str=`df -Th` echo -e "\033[32;40m$str\033[0m" ;; 6)echo -e "\033[34;40m Quit sucessfully!!! \033[0m" ;; 7)clear menu esac
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。