Linux下Dialog+Shell三层目录专业规范跳板机脚本
#Dialog+Shell介绍
Dialog+Shell结合使用,方能体现出Dialog图形化的效果,在运维的时候,使用图形化界面,能给你一个更直观的感受,相信你会喜欢上他的
#创建脚本目录
[root@localhost ~]# mkdir -p /scripts/tiaoban/{qqandroid,qqios,qqwxandroid,wxios,menu_list}
#禁止普通用户登陆
[root@localhost ~]# cat /etc/profile.d/tiaoban.sh [ $UID -ne 0 ] && sh /scripts/tiaoban/tiaoban.sh
#脚本目录结构
[root@localhost tiaoban]# tree /scripts/tiaoban/ /scripts/tiaoban/ ├── menu_list │ ├── one_menu │ └── one_option ├── qqandroid │ ├── three_directory │ │ ├── ip.txt │ │ ├── three_1_100_tiaoban.sh │ │ ├── three_menu │ │ └── three_option │ ├── tow_menu │ ├── tow_option │ └── tow_tiaoban.sh ├── qqios ├── qqwxandroid ├── tiaoban.sh └── wxios 6 directories, 10 files
#添加权限
[root@localhost tiaoban]# chmod +x /scripts/tiaoban/menu_list/{one_menu,one_option} [root@localhost tiaoban]# chmod +x /scripts/tiaoban/qqandroid/{tow_menu,tow_option} [root@localhost tiaoban]# chmod +x /scripts/tiaoban/qqandroid/three_directory/{three_menu,three_option}
#第一层目录脚本
[root@localhost tiaoban]# cat tiaoban.sh #!/bin/bash while : do stty susp ^@#$ #屏蔽Crtl +z stty intr ^@$# #屏蔽Ctrl +c stty quit ^*#$ #屏蔽Ctrl +l LJ=`dirname $0` dialog --title "Menu" --no-cancel --menu "Level directory" 12 35 5 `cat $LJ/menu_list/one_menu` 2> $LJ/menu_list/one_option SELECT=`cat $LJ/menu_list/one_option` if [ "$SELECT" == 1 ];thensh $LJ/qqandroid/tow_tiaoban.sh elif [ "$SELECT" == 2 ];thensh $LJ/qqios/tow_tiaoban.sh elif [ "$SELECT" == 3 ];thensh $LJ/wxandroid/tow_tiaoban.sh elsesh $LJ/wxios/tow_tiaoban.sh fi done
#第一层目录菜单
[root@localhost tiaoban]# cat /scripts/tiaoban/menu_list/one_menu 1 qqandroid 2 qqios(功能未开发) 3 wxandroid(功能未开发) 4 wxios(功能未开发)
#第二层目录脚本
[root@localhost tiaoban]# cat /scripts/tiaoban/qqandroid/tow_tiaoban.sh #!/bin/bash while : do LJ=`dirname $0` dialog --title "Menu" --menu "Secondary directory" 13 35 15 `cat $LJ/tow_menu` 2> $LJ/tow_option SELECT=`cat $LJ/tow_option` if [ "$SELECT" == 1 ];thensh $LJ/three_directory/three_1_100_tiaoban.sh elif [ "$SELECT" == 2 ];thensh $LJ/three_directory/three_101_200_tiaoban.sh elif [ "$SELECT" -eq 3 ];thensh $LJ/three_directory/three_201_300_tiaoban.sh else sh /scripts/tiaoban/tiaoban.sh fi done
#第二层目录菜单
[root@localhost tiaoban]# cat /scripts/tiaoban/qqandroid/tow_menu 1 qqandroid1-100服 2 qqandroid101-200服(功能未开发) 3 qqandroid201-300服(功能未开发) 4 返回上一级
#第三层目录脚本
[root@localhost tiaoban]# cat /scripts/tiaoban/qqandroid/three_directory/three_1_100_tiaoban.sh #!/bin/bash while : do LJ=`dirname $0` dialog --title "Menu" --menu "Three directory" 13 35 15 `cat $LJ/three_menu` 2> $LJ/three_option SELECT=`cat $LJ/three_option` function connect() {yh=`id`user=`echo $yh | awk -F" " '{print $2}' | awk -F"gid=" '{print $2}' | awk -F"(" '{print $2}' | awk -F")" '{print $1}'`ip=`head -$SELECT $LJ/ip.txt | tail -1`ssh -p 22 $user@$ip } if [ "$SELECT" == 5 ];thensh /scripts/tiaoban/qqandroid/tow_tiaoban.sh elif [ "$SELECT" == 6 ];thensh /scripts/tiaoban/tiaoban.sh elseconnect fi done
第三层目录菜单
[root@localhost tiaoban]# cat /scripts/tiaoban/qqandroid/three_directory/three_menu 1 qq1服 2 qqandroid2服(功能未开发) 3 qqandroid3服(功能未开发) 4 qqandroid...服(功能未开发) 5 返回上一级目录 6 返回首页
#IP文件展示
[root@localhost tiaoban]# cat /scripts/tiaoban/qqandroid/three_directory/ip.txt 192.168.1.103 192.168.1.104 192.168.1.105 192.168.1.106 192.168.1.107 192.168.1.108 192.168.1.109 192.168.1.110 192.168.1.111 192.168.1.112
#执行效果展示
1)普通用户登陆
2)第一级菜单栏
3)第二级菜单栏
4)第三级菜单栏
5)成功登陆展示
提示:在用普通用户登陆跳板机连接后端服务器的时候,普通用户按Crtl+c和Ctrl+z是没有效果的,所以普通用户只能直接连接到后端的服务器而不能直接登陆到跳板机终端
转载于:https://blog.51cto.com/yht1990/1793101
Linux下Dialog+Shell三层目录专业规范跳板机脚本相关推荐
- linux下执行shell脚本文件,Linux下使用shell脚本自动执行脚本文件
搜索热词 以下实例本人在Centos6.5 64位操作系统中使用 一.定时复制文件 a.在/usr/local/wfjb_web_back目录下创建 tomcatBack.sh文件 #将tomcat中 ...
- Linux下的文件系统与目录系统简介
Linux下的文件系统与目录系统简介 一. 文件系统 LINUX有四种基本文件系统类型:普通文件.目录文件.连接文件和特殊文件,可用file命令来识别. 普通文件:如文本文件.C语言元代码.SHELL ...
- linux下的shell操作mysql
(1)MySQL的启动 重启了一次服务器后,使用> mysql -u root -p登陆是出现下面的错误: ERROR 2002 (HY000): Can't connect to local ...
- linux下的shell脚本
linux下的shell脚本 一.Shell概述 二.Shell 解析器 三.Shell脚本入门 1. 脚本格式 2. 第一个Shell脚本:helloworld 3. 第二个Shell脚本:多命令处 ...
- linux在指定行添加内容,linux下利用shell在指定的行添加内容的方法
linux下利用shell在指定的行添加内容的方法 在linux的一些配置中总会要进行某个文件中的某行的操作,进行增加,修改,删除等操作. 而这里主要是进行的是指定的行添加数据的操作: 脚本如下: s ...
- linux nginx在哪个目录下,Linux下查看Nginx安装目录、版本号信息?
Linux环境下,怎么确定Nginx是以那个config文件启动的? 输入命令行: ps -ef | grep nginx 摁回车,将出现如下图片: master process 后面的就是 ngi ...
- linux下的shell脚本,linux下的shell脚本的使用
什么是shell? Shell是一个命令解释器,它在操作系统的最外层,负责直接与用户进行对话,把用户的输入解释给操作系统,并处理各种各样的操作系统的输出结果,输出到屏幕反馈给用户.这种对话方式可是交互 ...
- Linux下的shell脚本实战之用户创建
Linux下的shell脚本实战之用户创建 一.脚本要求 二.脚本内容 三.运行脚本 一.脚本要求 二.脚本内容 三.运行脚本 一.脚本要求 1.该脚本提示用户创建用户名和密码 2.判断输入的用户名是 ...
- linux下查看文件及目录个数
linux下查看文件及目录个数 1.查看当前文件和目录总数(不包括子目录): ls -l | wc -l 2.查看当前目录下文件个数(不包括子目录): ls -l |grep "^-&quo ...
最新文章
- 2分钟在线做出一张普氏分析图(Procrustes Analysis)
- 10万视频,所有图像均获授权,Facebook创建大规模Deepfake数据集
- js实时监听窗口变化总结
- 实战SSM_O2O商铺_35【商品】商品编辑之View层的实现
- SQL Serve里你总要去改变的3个配置选项
- aclocal-1.13: command not found
- 数据库死锁_死锁荔枝_解决方法
- 我的世界末日之后无限法则服务器,《我的世界》全新玩法无限法则上线
- qt5 linux apt get,Ubuntu 14.04下安装并配置Qt5.7.0
- unity3d 自动变化大小_自动做游戏(1),自动生成人物侧面图
- 性能测试--jmeter中使用jsonpath提取响应结果【17】
- 百度文库免费下载,精选六种方法!
- 视频教程-VBA从入门到精通(控件+类模块+ADO+SQL数据库)-Office/WPS
- 朴素的模式匹配(布鲁特-福斯算法)
- GUARDED_BY(c) 和 PT_GUARDED_BY(c)
- 两部苹果手机同步照片_如何将旧苹果手机音乐里面的歌曲同步到新苹果手机上...
- playbook中的block rescue always
- 最新·前端的工资分布情况 - 你拖后腿了吗?
- 如何获得小米手机4c的Root超级权限
- 电子设计教程47:流水灯电路-74HC245驱动器