新路程------sh脚本之无脑判断wifi热点是否有手机连接
2017-10-23 14:54
609 查看
最近写厂测文件,遇到这个蛋疼的问题,其实驱动里加个节点很简单,但是不加节点的话就比较麻烦了,需要通过log来判断
代码如下:
#!/bin/sh
#由于手机连接wifi热点成功会打印send eapol packet这句log,所以就这样获取是否连接成功
echo "wifi ap test start"
ifconfig wlan0 192.168.1.9 up
sleep 10
hostapd /etc/hostapd_wlan0.conf -B &
sleep 10
udhcpd /etc/udhcpd_wlan0.conf &
echo "please link the wifi mytestap"
sleep 40
dmesg > 3.txt
sed -n '/eapol/p' 3.txt >4.txt
chmod 777 4.txt
if [ -s ./4.txt ] ; then
echo "wifi ok" >> result.txt
else
echo "wifi NO" >> result.txt
fi
rm -rf 4.txt
rm -rf 3.txt
接下来
#获取以时间命名的文件并且将文件名替换为时间+mac地址
chmod 777 *
dir=`ls`
for i in $dir
do
ex=${i##*.}
先获取txt文件
if [ $ex == "txt" ];then
name=${i%.*}
new=${name}${mac}
echo $ex
rm -rf ${name}.txt
else
echo no
fi
done
代码如下:
#!/bin/sh
#由于手机连接wifi热点成功会打印send eapol packet这句log,所以就这样获取是否连接成功
echo "wifi ap test start"
ifconfig wlan0 192.168.1.9 up
sleep 10
hostapd /etc/hostapd_wlan0.conf -B &
sleep 10
udhcpd /etc/udhcpd_wlan0.conf &
echo "please link the wifi mytestap"
sleep 40
dmesg > 3.txt
sed -n '/eapol/p' 3.txt >4.txt
chmod 777 4.txt
if [ -s ./4.txt ] ; then
echo "wifi ok" >> result.txt
else
echo "wifi NO" >> result.txt
fi
rm -rf 4.txt
rm -rf 3.txt
接下来
#获取以时间命名的文件并且将文件名替换为时间+mac地址
chmod 777 *
dir=`ls`
for i in $dir
do
ex=${i##*.}
先获取txt文件
if [ $ex == "txt" ];then
name=${i%.*}
new=${name}${mac}
echo $ex
rm -rf ${name}.txt
else
echo no
fi
done
相关文章推荐
- 判断网络连接(是否连网、是否是手机流量或WIfi连接)
- 判断一个wifi热点是否连接成功
- WindowMobile如何判断网络有没连接和如何判WebService服务器地址是否正确(wifi有无打开)
- android判断网络或wifi是否连接
- [Android实例] 判断网络是否连接,然后选择网络类型(比如wifi等)来连接网络
- 通过iwpriv命令判断WIFI client和Ralink AP之间是否连接
- 常见的http状态响应码和判断手机网络是否连接以及连接类型
- Android之判断手机连接的网络类型是WIFI还是2G/3G/4G
- [Windows Phone 7]如何判断手机是否有网络连接
- iOS 开发判断应用是否连接WiFi,并跳转到设置中的WiFi设置页面。
- 获取所有连接到手机wifi热点的手机IP地址 和MAC地址。
- 判断手机是否连接网络
- iphone最牛判断当前手机网络连接类型wifi-2G-3G-4G-5G
- Linux 开发板4G转WiFi热点 手机连接热点上网(一 思路)
- 手机网络连接类型判断 2/3/4G网络 WiFi和无网络 工具类
- Android开发之判断网络(wifi、3G)是否连接
- WIN7建wifi热点,手机连接wifi上网~
- sh 脚本判断 tomcat是否已启动
- 判断是否连接到网络,如果有网,是3G还是WIFI
- 判断网络是否连接或是否连接wifi