bash迭代列表以进行频道跳跃

时间:2016-02-06 17:36:52

标签: bash ubuntu wifi

我想迭代列表以进行频道跳跃。值$ channel在迭代中是正确的,但“iw dev”命令没有获得正确的$ channel值。

channellist=(1 3 6 11)
while :
do
    for channel in "${channellist[@]}"
        do  
            sudo iw dev mon0 set channel $channel
            echo "$channel"
        done            
done

1 个答案:

答案 0 :(得分:0)

这会导致您的频道尽快切换我不确定是否有意。可能没有足够的时间让其他流程准确地收集数据:

$ channellist=(1 3 6 11)
$ while :
> do
>     for channel in "${channellist[@]}"
>         do
>             time echo some command set channel $channel
>             echo "$channel"
>             sleep 1
>         done
> done
some command set channel 1

real    0m0.000s
user    0m0.000s
sys 0m0.000s
1
some command set channel 3

real    0m0.000s
user    0m0.000s
sys 0m0.000s
3
some command set channel 6

real    0m0.000s
user    0m0.000s
sys 0m0.000s
6
some command set channel 11

real    0m0.000s
user    0m0.000s
sys 0m0.000s
11
some command set channel 1

real    0m0.000s
user    0m0.000s
sys 0m0.000s
1
^C
$

编辑:

正如您在上面的信息中看到的那样,命令在0.0005 s下运行,授予的回声可能比sudo快得多,但它仍然可能只有几分之一。