Getting wpa_action to run dhclient after wpa_supplicant connects

Curtis Larsen curtlarsen
Tue Apr 12 05:59:57 PDT 2011


I run the following two commands:

sudo ./wpa_supplicant -c /etc/wpa_supplicant/WIFI.conf -i wlan2 -d
sudo wpa_cli -a /sbin/wpa_action.sh

....and my wpa_action.sh looks like this:

------------------------------------------------------------
#!/bin/sh

IFNAME=$1
CMD=$2

if [ "$CMD" == "CONNECTED" ]; then
    SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
    dhclient wlan2
fi

if [ "$CMD" == "DISCONNECTED" ]; then
    # remove network configuration, if needed
fi
---------------------------------------------------------------------

But I get the following output from the wpa_cli command:

-----------------------------------------------------------
Selected interface 'wlan2'
[: 9: CONNECTED: unexpected operator
/sbin/wpa_action.sh: 13: Syntax error: "fi" unexpected
----------------------------------------------------------------------------------

So ... what am I doing wrong?  And how do I tell wpa_action to run
"dhclient wlan2" after wpa_supplicant successfully connects?  Is this
possible?

Thanks,

Curtis



More information about the Hostap mailing list