使用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 注 ...
随机推荐
- 发邮件、排序、FIFO
发送邮件.py: import smtplib from email.mime.text import MIMEText def email(receiver, title='标题', b ...
- html5 datalist
教程:http://www.w3school.com.cn/html5/html5_datalist.asp 提供自动完成的文本框
- 《A computer-aided healthcare system for cataract classification and grading based on fundus image analysis》学习笔记
Abstract This paper presents a fundus image analysis based computer aided system for automatic class ...
- vnc搭建
PS:偶以前基本不用Linux的远程图形桌面,前几天有开发的同事配置CentOS的vnc有问题,找我解决,就顺便记录总结一下,这个总结是比较完整的.下面的配置在CentOS5.x和6.x.SUSE企业 ...
- JAVA的初始化顺序
这里主要是介绍JAVA的类的初始化顺序,比较基础:主要是以例子演示为主: 例子一: 1 package com.cnblog.GDUTtiantian; 2 3 /** 4 * 5 * @author ...
- make编译
Makefile 值得一提的是,在Makefile中的命令,必须要以[Tab]键开始. 什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了 ...
- C++动态(显式)调用 C++ dll
1.创建DLL新项目Dll1,Dll1.cpp: extern "C" __declspec(dllexport) const char* myfunc() { return &q ...
- dotnet core瘦身发布
需要安装nuget包Microsoft.Packaging.Tools.Trimming然后利用如下命令发布dotnet publish -r win10-x64 -c release --self- ...
- 2018-2019-2 20175230 实验三《Java面向对象程序设计》实验报告
目录 实验三 实验三 敏捷开发与XP实践 实验内容 实验要求 实验步骤 (一) 编码标准 (二)敏捷开发与XP (三)敏捷开发与XP 实验体会 实验三 实验三 敏捷开发与XP实践 实验内容 1.XP基 ...
- css经典布局—Sticky footers布局
参考:http://www.w3cplus.com/CSS3/css-secrets/sticky-footers.html 效果:将footer固定到底部.文章内容不足满屏时 footer在底部,超 ...