使用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 注 ...
随机推荐
- PB函数大全【转自 http://blog.csdn.net/xiaoxian8023 】
Abs()功能计算绝对值.语法Abs ( n )参数n:要得到绝对值的数值型变量或表达式返回值返回值的数据类型与n的数据类型相同,函数执行成功时返回n的绝对值.如果参数n的值为NULL,Abs()函数 ...
- strom ui Topology 可视化视图各个指标含义说明
In the visualization, spout components are represented as blue, while bolts are colored between gree ...
- 尝试asp.net mvc 基于controller action 方式权限控制方案可行性(转载)
微软在推出mvc框架不久,短短几年里,版本更新之快,真是大快人心,微软在这种优秀的框架上做了大量的精力投入,是值得赞同的,毕竟程序员驾驭在这种框架上,能够强力的精化代码,代码层次也更加优雅,扩展较为方 ...
- 关于QT和SQLite以及XML
就关于qt连接使用sqlite折腾了一晚上.倒也不全是因为数据库连接的问题, 主要还是数据格式各自出问题. 原来的数据库是access, 为了导入linux下的sqlite, 我把其输出格式改成了xm ...
- Python-使用PyQT生成图形界面
1.安装PyQT5以及QT Designer工具包 pip install PyQt5 pip install PyQt5-tools -i http://pypi.douban.com/simple ...
- 01_python_初始python
一.初始python python是一门解释型语言,弱类型语言 / python解释器最为常用的是cpython(官方) 弱类型语言: a = 1 a = 'alex' #说明变量a既可以是整 ...
- POJ 2442(优先队列 k路归并 堆)
Description Given m sequences, each contains n non-negative integer. Now we may select one number fr ...
- linux下发送报警邮件(mailx)
本文章主要解决 linux下监控到系统状况后怎么发邮件报警的问题. 如果你是最小化安装的centos/redhat 系统,是没有自带mailx的,也就是没有mail 命令. 解决办法 yum -y i ...
- iOS开发-带Placeholder的UITextView实现
iOS中UITextField带有PlaceHolder属性,可以方便用于提示输入.但是同样可以进行文本输入的UITextView控件则没有PlaceHolder属性,还是有些不方便的,尤其是对于略带 ...
- java操作数据库的基本方法
此次开发工具为eclipse,才有的数据库驱动是mysql-connector-java-5.1.8-bin.jar 第一步,在eclipse的工程目录中引用mysql驱动 驱动下载地址:https: ...