使用whiptail开发linux环境交互式对话框
#!/bin/bash oem=$(/bin/cat /opt/jdwa/etc/oem)
systype=$(/bin/cat /opt/jdwa/etc/systype)
export select_ethname
echo "oem:"$oem
echo "systype:"$systype
CheckIPAddress()
{
echo $ |grep "^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$" > /dev/null
if [ $? = ]; then
return
else
a=`echo $ | awk -F. '{print $1}'`
b=`echo $ | awk -F. '{print $2}'`
c=`echo $ | awk -F. '{print $3}'`
d=`echo $ | awk -F. '{print $4}'`
for loop in $a $b $c $d
do
if [ $loop -gt ] || [ $loop -lt ]; then
return
fi
done
fi
} while(())
do
if [ "$oem"x = "QIANZHI"x ]; then
if [ "$systype"x = "int"x ]; then
whiptail --title "Config network" --cancel-button "Quit" --menu "Select Config Network Device " "man" "" "tun" "" "peer_tun" "" > data
exitstatus=$?
if [ $exitstatus != ]; then
break
fi
select_ethname=$(/bin/cat data)
echo "Select Config Network Device:"$select_ethname
fi
if [ "$systype"x = "ext"x ]; then
whiptail --title "Config network" --cancel-button "Quit" --menu "Select Config Network Device " "tun" "" "peer_tun" "" >data
exitstatus=$?
if [ $exitstatus != ]; then
break
fi
select_ethname=$(/bin/cat data)
echo "Select Config Network Device:"$select_ethname
fi
fi
if [ "$oem"x = "COMPONENT"x ]; then
if [ "$systype"x = "int"x ]; then
whiptail --title "Config network" --cancel-button "Quit" --menu "Select Config Network Device " "man" "" > data
exitstatus=$?
if [ $exitstatus != ]; then
break
fi
select_ethname=$(/bin/cat data)
echo "Select Config Network Device:"$select_ethname
fi
if [ "$systype"x = "ext"x ]; then
break
fi
fi if [ "$select_ethname"x = "man"x ] || [ "$select_ethname"x = "tun"x ]; then
if [ "$select_ethname"x = "man"x ]; then
netinfo=$(/bin/cat /opt/jdwa/etc/man)
else
netinfo=$(/bin/cat /opt/jdwa/etc/tun0)
fi
IFS='/' arr=($netinfo)
IPaddr=$(whiptail --inputbox "Please input interface "$select_ethname" IpAddr :" ${arr[]} --title "Config NetWork" >& >& >&)
exitstatus=$?
if [ $exitstatus != ]; then
continue
fi
Maskaddr=$(whiptail --inputbox "Please input interface "$select_ethname" MaskAddr :" ${arr[]} --title "Config NetWork" >& >& >&)
exitstatus=$?
if [ $exitstatus != ]; then
continue
fi
GateWay=$(whiptail --inputbox "Please input interface "$select_ethname" GateWay" ${arr[]} --title "Config NetWork" >& >& >&)
exitstatus=$?
if [ $exitstatus != ]; then
continue
fi
if [ "$IPaddr"x = ""x ] || [ "$Maskaddr"x = ""x ]; then
whiptail --title "Message Box" --msgbox "Incomplete input information, configuration failed!"
continue
fi
CheckIPAddress $IPaddr
if [ $? != ]; then
whiptail --title "Message Box" --msgbox "IPaddr Error, configuration failed!"
continue
fi
CheckIPAddress $Maskaddr
if [ $? != ]; then
whiptail --title "Message Box" --msgbox "Maskaddr Error, configuration failed!"
continue
fi
if [ "$GateWay"x != ""x ]; then
CheckIPAddress $GateWay
if [ $? != ]; then
whiptail --title "Message Box" --msgbox "GateWay Error, configuration failed!"
continue
fi
fi
if (whiptail --title "Config NetWork" --yesno "Please make sure to save the configuration.
Devname : "$select_ethname"
IpAddr : "$IPaddr"
MaskAddr: "$Maskaddr"
GateWay : "$GateWay 0 0) then
if [ "$select_ethname"x = "man"x ]; then
echo $IPaddr"/"$Maskaddr"/"$GateWay> /opt/jdwa/etc/man
else
echo $IPaddr"/"$Maskaddr"/"$GateWay> /opt/jdwa/etc/tun0
fi
else
exitstatus=$?
if [ $exitstatus != ]; then
continue
fi
fi
fi
if [ "$select_ethname"x = "peer_tun"x ]; then
compaddr=$(/bin/cat /opt/jdwa/etc/peer_tun0)
IPaddr=$(whiptail --inputbox "Please input interface "$select_ethname" IpAddr :" $compaddr --title "Config network" >& >& >&)
exitstatus=$?
if [ $exitstatus != ]; then
continue
fi
if [ "$compaddr"x != ""x]; then
CheckIPAddress $compaddr
if [ $? != ]; then
whiptail --title "Message Box" --msgbox "IPaddr Error, configuration failed!"
continue
fi
fi
if (whiptail --title "Config NetWork" --yesno "Please make sure to save the configuration.
Devname : "$select_ethname"
IpAddr : "$IPaddr 0 0) then
echo $IPaddr> /opt/jdwa/etc/peer_tun0
else
exitstatus=$?
if [ $exitstatus != ]; then
continue
fi
fi fi
done
使用whiptail开发linux环境交互式对话框的更多相关文章
- Unix/Linux环境C编程新手教程(12) openSUSECCPP以及Linux内核驱动开发环境搭建
1. openSUSE是一款优秀的linux. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaXRjYXN0Y3Bw/font/5a6L5L2T/font ...
- linux环境开发私房菜
1,各种linux 平台GUI开发IDE环境 2,C/C++ 好的编译器 gcc/emcs;
- Unix/Linux环境C编程入门教程(12) openSUSECCPP以及Linux内核驱动开发环境搭建
1. openSUSE是一款优秀的linux. 2.选择默认虚拟机 3.选择稍后安装操作系统 4.选择linux opensuse 5. 选择默认虚拟机名称 6.设置处理器为双核. 7.内存设置为2 ...
- LINUX环境下SVN安装与配置(利用钩子同步开发环境与测试环境)
安装采用YUM一键安装: 1.环境Centos 6.6 2.安装svnyum -y install subversion 3.配置 建立版本库目录mkdir /www/svndata svnserve ...
- 【ARM-Linux开发】Linux环境下使用eclipse开发C++动态链接库程序
Linux环境下使用eclipse开发C++动态链接库程序 Linux中也有类似windows中DLL的变成方法,只不过名称不同而已.在Linux中,动态链接叫做Standard Object,生成的 ...
- Linux 环境下 C++ 的开发编译
Linux环境下C++程序的开发编译学习笔记 环境:vmware 运行下的Ubuntu 16.04 姓名:谢津 时间:2018/5/24 内容:1)vim的安装及配置:2)第一个C++程序的编写与编译 ...
- 在桌面Linux环境下开发图形界面程序的方案对比
在Linux下开发GUI程序的方法有很多,比如Gnome桌面使用GTK+作为默认的图形界面库,KDE桌面使用Qt作为默认的图形界面库,wxWidgets则是另一个使用广泛的图形库,此外使用Java中的 ...
- Linux服务器开发/测试环境搭建-流程
1.MariaDB yum 安装/初始化/授远程权限 yum安装 在MariaDB官网根据Linux系统查找您所需要的db版本:https://downloads.mariadb.org/mariad ...
- Python_基于Python同Linux进行交互式操作实现通过堡垒机访问目标机
基于Python同Linux进行交互式操作实现通过堡垒机访问目标机 by:授客 QQ:1033553122 欢迎加入全国软件测试交流群:7156436 实现功能 1 测试环境 1 代码实践 2 注 ...
随机推荐
- 国内代码托管平台(Git)
可以说GitHub的出现完全颠覆了以往大家对代码托管网站的认识.GitHub不但是一个代码托管网站,更是一个程序员的SNS社区.GitHub真正迷人的是它的创新能力与Geek精神,这些都是无法模仿的. ...
- 【DirectX】 AudioVideoPlayback 中的事件BUG
当访问 Video 中的 Audio 属性时,会造成 Video 的所有事件失效.经过反汇查看源码,原来在访问Audio属性时,Audio会通过当前Video对象创建一个新实例.而这个新实例会覆盖掉当 ...
- telerik:RadGrid 分组自动展开
在 MasterTableView 加上 GroupsDefaultExpanded = " true " 即可 自动展开分组下面的子项
- .net4.0 请求HTTPS出错:未能创建 SSL/TLS 安全通道
两种方法: 1.在代码中修改 ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;// SecurityProtocol ...
- 网络基础、多线程、ftp任务铺垫
一.网络基础 学习网络编程,了解一些网络基础的知识是必不可少的,下面学习一些基础的网络知识: 1.我们的电脑里有网卡,网卡里有mac地址: 2.我到某个地方插上网线,路由器或交换机中的DHCP服务为我 ...
- Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)
题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...
- Linux 下创建 sftp 用户并限定目录
Linux 下创建 sftp 用户并限定目录 1.创建 sftpUser 用户组 [root@XXX ~]# groupadd sftpUser 2.创建 sftpUser 用户并指定目录 [root ...
- 重拾 BFC、IFC、GFC、FFC
温故知新,巩固基础 从 FC 开始 FC,Formatting Context,格式化上下文,是 W3C CSS2.1 规范中的一个概念,定义的是页面中一块渲染区域,并且有一套渲染规则,它决定了其子元 ...
- JavaScript 的 Async\/Await 完胜 Promise 的六
参考:http://www.10tiao.com/html/558/201705/2650964601/1.html Node 现在从版本 7.6 开始就支持 async/await 了. 简介: A ...
- 将页面中表格数据导出excel格式的文件(vue)
近期由于项目需要,需要将页面中的表格数据导出excel格式的文件,折腾了许久,在网上各种百度,虽然资料不少,但是大都不全,踩了许多坑,总算是皇天不负有心人,最后圆满解决了. 1.安装相关依赖(npm安 ...