Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Notice removed Draw attention by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Tweeted twitter.com/StackUnix/status/936277869633957890
Notice added Draw attention by Philip Kirkbride
Bounty Started worth 100 reputation by Philip Kirkbride
edited tags
Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174
added 194 characters in body
Source Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174

Normally when I run wpa_supplicant I'll get some output like this:

Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

The problem is it just keeps trying over and over.

Is there a way I can tell wpa_supplicant to quit as soon as it gets an obvious error like wrong key?

I'm on an older embedded device with wpa_supplicant v2.1.


I wrote a workaround for monitoring wpa_supplicant for incorrect keys. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # Create conf file with ssid and password
  wpa_passphrase "$ssid" "$password" > /etc/wpa_supplicant/wpa_supplicant.conf

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Note: the above block is inside a subshell in a script.

It seemed to work initially but over time I found sometimes it would cause the whole script to fail when the password was fine. Other times it would work as expected.

There must be a better way to do this.


Edit: Maybe I should be using wpa_cli here instead?

Normally when I run wpa_supplicant I'll get some output like this:

Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

The problem is it just keeps trying over and over.

Is there a way I can tell wpa_supplicant to quit as soon as it gets an obvious error like wrong key?

I'm on an older embedded device with wpa_supplicant v2.1.


I wrote a workaround for monitoring wpa_supplicant for incorrect keys. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Note: the above block is inside a subshell in a script.

It seemed to work initially but over time I found sometimes it would cause the whole script to fail when the password was fine. Other times it would work as expected.

There must be a better way to do this.

Normally when I run wpa_supplicant I'll get some output like this:

Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

The problem is it just keeps trying over and over.

Is there a way I can tell wpa_supplicant to quit as soon as it gets an obvious error like wrong key?

I'm on an older embedded device with wpa_supplicant v2.1.


I wrote a workaround for monitoring wpa_supplicant for incorrect keys. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # Create conf file with ssid and password
  wpa_passphrase "$ssid" "$password" > /etc/wpa_supplicant/wpa_supplicant.conf

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Note: the above block is inside a subshell in a script.

It seemed to work initially but over time I found sometimes it would cause the whole script to fail when the password was fine. Other times it would work as expected.

There must be a better way to do this.


Edit: Maybe I should be using wpa_cli here instead?

added 207 characters in body
Source Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174

I'm running a script which is a hacky way of monitoring wpa_supplicant for incorrect key. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Normally when I run wpa_supplicant I'll get some output like this:

Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

The problem is it just keeps trying over and over.

Is there a way I can tell wpa_supplicant to quit as soon as it gets an obvious error like wrong key?

I'm on an older embedded device with wpa_supplicant v2.1.


I wrote a workaround for monitoring wpa_supplicant for incorrect keys. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Note: the above block is inside a subshell in a script.

It seemed to work initially but over time I found sometimes it would cause the whole script to fail when the password was fine. Other times it would work as expected.

There must be a better way to do this.

I'm running a script which is a hacky way of monitoring wpa_supplicant for incorrect key. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Normally when I run wpa_supplicant I'll get some output like this:

Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

The problem is it just keeps trying over and over.

Is there a way I can tell wpa_supplicant to quit as soon as it gets an obvious error like wrong key?

I'm on an older embedded device with wpa_supplicant v2.1.

Normally when I run wpa_supplicant I'll get some output like this:

Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect

The problem is it just keeps trying over and over.

Is there a way I can tell wpa_supplicant to quit as soon as it gets an obvious error like wrong key?

I'm on an older embedded device with wpa_supplicant v2.1.


I wrote a workaround for monitoring wpa_supplicant for incorrect keys. Using grep on wpa_supplicant (with stdbuf based on Stéphane Chazelas' comment here):

  # If wifi key is wrong kill subshell
  subshell=$BASHPID
  (sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
    | grep -m 1 "pre-shared key may be incorrect" \
    && kill -s PIPE "$subshell") &

Note: the above block is inside a subshell in a script.

It seemed to work initially but over time I found sometimes it would cause the whole script to fail when the password was fine. Other times it would work as expected.

There must be a better way to do this.

Rollback to Revision 3
Source Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174
Loading
added 150 characters in body
Source Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174
Loading
Name correction
Source Link
Jeff Schaller
  • 68.4k
  • 35
  • 120
  • 257
Loading
edited body
Source Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174
Loading
Source Link
Philip Kirkbride
  • 10.7k
  • 32
  • 103
  • 174
Loading