wpa_cli -a option

Roy Marples uberlord
Mon Feb 6 07:16:24 PST 2006


On Sunday 05 February 2006 17:48, Jeff Sadowski wrote:
> ok in my startup script I have the following
>
>  ERR=""
>  OUT=`wpa_supplicant -BWw -Dmadwifi -iath0 \
>       -c/etc/wpa_supplicant.conf 2>&1` || ERR=OUT
>  sleep 2
>  if [ "$ERR" = "" ];then
>   ERR=not_connected
>   while [ "$ERR" != "" ];do
>    ERR=""
>    OUT=`wpa_cli -iath0 \
>         -a/etc/init.d/wpa_cli -B 2>&1` || ERR=OUT
>    if [ "$ERR" != "" ];then
>     echo -e "$ERR"
>     echo trying again in 2 seconds
>     sleep 2
>    fi
>   done
>  else
>   echo -e "$ERR"
>  fi
>
> Is there a better way? rather than erroring out if
> wpa_cli doesn't connect right away?
>

The best way is to have to different scripts.

Script 1 launches wpa_supplicant and then wpa_cli. If both launch OK then 
return 0, otherwise 1. Assume that we have not associated. It is best to 
return right away here.

Script 2 is launched by wpa_cli (specified by the -a option) when 
wpa_supplicant associates or dis-assciates with an AP). So script 2 is 
responsible for setting the interface up (static IP, routing, dhcp, etc) or 
removing configuration. It is important that this script never takes the 
interface down as this would stop wpa_supplicant from working!

Thanks

-- 
Roy Marples <uberlord at gentoo.org>
Gentoo Linux Developer




More information about the Hostap mailing list