您的位置:首页 > 其它

新路程------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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: