shell之菜单+跳板机(跳板机管理及连接脚本与下一个for循环的脚本配合使用)
2015-11-19 16:59
756 查看
#!/bin/bash Wap_Server="10.0.0.1" Mem_Server="10.0.0.2" Erp01_Server="10.0.0.3" Erp02_Server="10.0.0.4" ErpOld_Server="10.0.0.5" Backup_Server="10.0.0.6" Monitor_Server="10.0.0.7" DOSSH=/home/lichuang/scrips/dossh.sh #这是一个远程ssh批量远程执行的脚本 PROT=22 function CheckUser(){ if [ $UID -ne 888 ] then echo 'PLS SU - 888' exit fi function MENU(){ echo -e "\033[1;32m <<Ailyun jume MENU>> \033[0m" cat <<EOF ########################################## 1.Administration ALL server 2.Connect ONE server 3.Exit ########################################## EOF } function FIRST(){ clear echo -e "\033[1;32m <<Ailyun jume Administration menu>> \033[0m" MENU read -p "Please input num: " num case $num in 1) Admin_Server ;; 2) Connect_Server ;; 3) exit ;; *) clear echo -e "\033[31m############################################\033[0m" echo -e "\033[31m#\033[0m""\033[1;5;31m Input error Num ,Please input again \033[0m""\033[31m #\033[0m" echo -e "\033[31m############################################\033[0m" sleep 3 FIRST esac } function Admin_Menu(){ echo -e "\033[1;32m <<Ailyun jume Administration menu>> \033[0m" cat <<EOF ########################################## 1.df -h 2.free -m 3.uptime 4.iostat 5.ifconfig 6.OTHER what you want 7.Return to the upper menu 8.Exit ########################################## EOF } function Admin_Server(){ clear Admin_Menu read -p "Please input num: " num case $num in 1) /bin/bash $DOSSH "df -h" Admin_Server ;; 2) /bin/bash $DOSSH "free -m" Admin_Server ;; 3) /bin/bash $DOSSH "uptime" Admin_Server ;; 4) /bin/bash $DOSSH "iostat" Admin_Server ;; 5) /bin/bash $DOSSH "ifconfig" Admin_Server ;; 6) echo "Temporarily not supported sorry" Admin_Server ;; 7) FIRST ;; 8) exit ;; *) clear echo -e "\033[31m############################################\033[0m" echo -e "\033[31m#\033[0m""\033[1;5;31m Input error Num ,Please input again \033[0m""\033[31m #\033[0m" echo -e "\033[31m############################################\033[0m" sleep 3 Admin_Server esac } function Connect_Menu(){ echo -e "\033[1;32m <<Ailyun jume connect menu>> \033[0m" cat <<EOF ============================================ 1. Wap__$Wap_Server 2. Mem__$Mem_Server 3. Erp01__$Erp01_Server 4. Erp02__$Erp02_Server 5. ErpOld__$ErpOld_Server 6. Backup__$Backup_Server 7. Monitor__$Monitor_Server 8. Return to the upper menu 9. Exit ============================================ EOF } function Connect_Server(){ clear Connect_Menu read -p "Please input num: " num case $num in 1) ssh -p$PROT $Wap_Server ;; 2) ssh -p$PROT $Mem_Server ;; 3) ssh -p$PROT $Erp01_Server ;; 4) ssh -p$PROT $Erp02_Server ;; 5) ssh -p$PROT $ErpOld_Server ;; 6) ssh -p$PROT $Backup_Server ;; 7) ssh -p$PROT $Monitor_Server ;; 8) FIRST ;; 9) clear exit ;; *) clear echo -e "\033[31m############################################\033[0m" echo -e "\033[31m#\033[0m""\033[1;5;31m Input error Num ,Please input again \033[0m""\033[31m #\033[0m" echo -e "\033[31m############################################\033[0m" sleep 3 Server esac } main (){ CheckUser FIRST } main
相关文章推荐
- android wifi 无线调试
- 底部Popwindow形式菜单的类的封装
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- 一步一步跟我学易语言之第二个易程序菜单设计
- IE右键菜单被修改
- jQuery菜单插件用法实例
- shell字符串操作详解
- ASP动态级联菜单实现代码
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法
- Shell脚本解压rpm软件包