WLANチャネルを変更して監視モードを設定するBashスクリプト

WLANチャネルを変更して監視モードを設定するBashスクリプト

私はやや奇妙な問題に遭遇しました(または少なくとも私にとってはそうです)。

次のコマンドを実行するとき:

sudo iwconfig wlx00c0ca959fe2 mode monitor channel 1

すべてが正常です。 WLANアダプタはチャネル1の監視モードに設定されています。

「自動化」するために、次のbashスクリプトを作成しました。

#!/bin/bash

if [ "$1" != "" ] && [ "$2" != "" ]; then
    echo "Shutting down $1"
    echo "channel: $2"
    echo "wlan interface $1" 
    sudo ifconfig $1 down
    echo "Configuring monitor mode for $1 channel $2"
    sudo iwconfig $1 mode monitor channel $2
    echo "Powering on $1" 
    sudo ifconfig $1 up
else
    echo "No input parameter was given using wlx00c0ca959fe2 as default" 
    echo "Shutting down wlx00c0ca959fe2" 
    sudo ifconfig wlx00c0ca959fe2 down
    echo "Configuring monitor mode for wlx00c0ca959fe2 channel 11" 
    sudo iwconfig wlx00c0ca959fe2 mode monitor channel 11
    echo "Powering on wlx00c0ca959fe2" 
    sudo ifconfig wlx00c0ca959fe2 up
fi

私のraspberryPiでは正しく動作しますが、私のラップトップ(Mint 19.1 cinnanmon)では次のエラーコードが表示されます。

sudo ./setMonitorMode.sh
No input parameter was given using wlx00c0ca959fe2 as default
Shutting down wlx00c0ca959fe2
Configuring monitor mode for wlx00c0ca959fe2 channel 11
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device wlx00c0ca959fe2 ; Device or resource busy.
Powering on wlx00c0ca959fe2

これが何であるかを知っている人はいますか?オプション/アイデアが足りません。

よろしくお願いします!

ありがとう、キャスパー

編集する:

-x 使用:

+ '[' wlx00c0ca959fe2 '!=' '' ']'
+ '[' 10 '!=' '' ']'
+ echo 'Shutting down wlx00c0ca959fe2'
Shutting down wlx00c0ca959fe2
+ echo 'channel: 10'
channel: 10
+ echo 'wlan interface wlx00c0ca959fe2'
wlan interface wlx00c0ca959fe2
+ sudo ifconfig wlx00c0ca959fe2 down
+ echo 'Configuring monitor mode for wlx00c0ca959fe2 channel 10'
Configuring monitor mode for wlx00c0ca959fe2 channel 10
+ sudo iwconfig wlx00c0ca959fe2 mode monitor channel 10
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device wlx00c0ca959fe2 ; Device or resource busy.
+ echo 'Powering on wlx00c0ca959fe2'
Powering on wlx00c0ca959fe2
+ sudo ifconfig wlx00c0ca959fe2 up

また、同じ結果でIPコマンドを試しました。

ベストアンサー1

おすすめ記事