linux shell脚本的问题,字符串比较出问题

bossjuemfc 2016-11-30 07:08:39
我想通过此脚本实现获取ip的功能,由于嵌入式系统不稳定,而且经过我实验,只有Bit Rate=11 Mb/s的时候dhcp才能分配到ip,所以就写了个简单的脚本,判断系统的Bit Rate是不是等于11 Mb/s,等于的话就执行dhcp。
但是现在程序出现问题,进了循环后一直退不出来,打印了Bit_Rate_test的值,含有11 Mb/s。
怀疑是字符串表示方式不对,求大神帮忙看看。
这是shell脚本:

[code=text][#!/bin/bash
Bit_Rate1="Bit Rate=11 Mb/s"
insmod /lib/modules/3.10.17/kernel/driver/net/wireless/rt2x00/rt5572.ko
insmod /lib/modules/3.10.17/kernel/net/wireless/cfg80211.ko
insmod /lib/modules/3.10.17/kernel/net/mac80211/mac80211.ko

ifconfig ra0 up &
iwlist scanning
sleep 1
iwconfig ra0 ap 6C:B0:CE:16:66:C0

Bit_Rate_test=`iwconfig ra0 | grep Bit`
echo "start link"

while [ "$Bit_Rate1" != "$Bit_Rate_test" ]
do
echo $Bit_Rate_test
sleep 1
iwconfig ra0 ap 6C:B0:CE:16:66:C0
sleep 1
Bit_Rate_test=`iwconfig ra0 | grep Bit`
done
udhcpc -i ra0 -n
/code]
...全文
391 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,597

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 驱动开发/核心开发
社区管理员
  • 驱动开发/核心开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧