使用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 注 ...
随机推荐
- Android创建AVD模拟器
Android创建AVD模拟器 1. 新建一个安卓工程如下: 2. 点击windows里的 Android Virtual Device Manager,如果第一次安装 adt-bundle启动会出现 ...
- poj 2886 线段树的更新+反素数
Who Gets the Most Candies? Time Limit: 5000 MS Memory Limit: 0 KB 64-bit integer IO format: %I64d , ...
- 跨 iframe 传输数据
背景:项目用 easyUI 写前端,窗口使用 easyui-window 内嵌套 iframe 展示页面.遇到需要在窗口间传输数据的需求. 解决方案 获取 iframe 对象,然后通过获取的 ifra ...
- ASP.NET Core CMS管理后台
ASP.NET Core+LayUI+MySql CMS管理后台,主要功能包括 登录.修改密码,账号管理,菜单管理,角色权限管理等 由于工作之外,抽时间写的,用于学习交流,请慎重用于生产环境 项目概要 ...
- 【CJOJ2375】 【HZOI 2015】偏序 II(cdq分治,树状数组)
传送门 CJOJ Solution 具体实现参考上一篇Blog(四维偏序) 代码实现1(cdq+cdq+cdq+BIT) /* mail: mleautomaton@foxmail.com autho ...
- Android Parcelable using Kotlin
Kotlin 有 extension 可以很方便的让类继承 Parcelable 接口. 项目中引入一个较新版本的 Kotlin 引入 Kotlin extensions classpath &quo ...
- Android--------------BroadcastReceiver的学习
一.广播的注册方式 发送广播: Intent mIntent = new Intent("com.simware.BroadcastReceiverDemo"); mIntent. ...
- 【友情链接】各位dalao的博客
同省神犇 HA队长 __stdcall HA chty_syq为文文讲过字符串 HA cdcq为文文讲过后缀数组① ② Bluesky007超强的 外省神犇 知名OIer黄学长 一个可爱的蓝孩子qwq ...
- 自用 docker-compose
version: '3.1' services: mysql: image: mysql: command: --default-authentication-plugin=mysql_native_ ...
- 为什么要先 git add 才能 git commit
1. git 的 add ,是一个容易引起疑问的命令.在 subversion 中的 svn add 动作是将某个文件加入版本控制,而 git add的意义完全不同. 同时, git diff --c ...