Tom Knudsen
Tom Knudsen

Reputation: 83

Setting interface card into monitor mode

How come this code does not work, gives errors in line 8 and 12

./monitor.sh: line 8: [iface: command not found ./monitor.sh: line 12: [iface: command not found

iface should be the variable, here is the code

#!/bin/bash

ip link set wlan1

echo Please enter your wifi interface of choice
read iface

if [iface == wlan1]
then
   iw wlan1 set monitor control
   echo wlan1 is set in monitor mode
elif [iface == wlan0]
then
   iw wlan0 set monitor control
   echo wlan0 is now set in monitor mode
else
   echo No card was put into monitor mode, try again
fi

Upvotes: 0

Views: 98

Answers (2)

Dan D.
Dan D.

Reputation: 74655

if [iface == wlan1] should be if [ $iface == wlan1 ]. Both the spaces and the sigil are required.

Upvotes: 0

Tomasz Czyżak
Tomasz Czyżak

Reputation: 1118

use $iface after you read in line 6 and if format is incorrect

should be:

if [ $iface == "wlan1" ]

Upvotes: 1

Related Questions