I implemented a function in order to connect my device to an access point which contains :
iw mlan0 connect $SSID
udhcpc -i mlan0
while : ; do
echo "Pausing until connection established"
mlan0_ip=`/sbin/ifconfig mlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
if [ -z "$mlan0_ip" ]
then
sleep 1
else
break
fi
done
I don't understand why the iw mlan0 connect $SSID command keep the prompt. Indeed, it is blocked on
[ 6231.764960] wlan: SCAN COMPLETED: scanned AP count=9
[ 6231.798636] wlan: Connected to bssid 1a:XX:XX:XX:52:66 successfully
[ 6231.808511] IPv6: ADDRCONF(NETDEV_CHANGE): mlan0: link becomes ready
udhcpc (v1.22.1) started
Sending discover...
Sending discover...
Sending discover...
[ 6241.126472] ADDBA RSP: Failed(1a:XX:XX:XX:52:66 tid=6)
Sending discover...
[ 6264.263093] ADDBA RSP: Failed(1a:XX:XX:XX:52:66 tid=6)
Sending select for 192.168.50.33...
[ 6264.497054] ADDBA RSP: Failed(1a:XX:XX:XX:52:66 tid=6)
Lease of 192.168.50.33 obtained, lease time 43200
Basically I never enter into the while loop.. I would like to execute some others command after network configuration
Try putting an ampersand at the end of the command, it will run in background allowing the next command to execute.
iw mlan0 connect $SSID &
udhcpc -i mlan0
while : ; do
echo "Pausing until connection established"
mlan0_ip=`/sbin/ifconfig mlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
if [ -z "$mlan0_ip" ]
then
sleep 1
else
break
fi
done
But I can see in the log a message of udhcpd, and then the problem will be it, because if iw started and udhpcd started but the loop is not starting, you can try to put a ampersand also on the second command.
udhcpc -i mlan0 &