#!/bin/sh #get current SSID LIST=`iwconfig wlan0 | awk -F":" '/ESSID/{print $2}'` echo Current connection: $LIST #Quit if already connected if [ $LIST = "\"$1\"" ]; then echo \"$1\" is already connected exit 1; fi #Bring up wlan and scan for SSIDs ifconfig wlan0 up if [ -z `iwlist wlan0 scan | grep -m 1 -o \"$1\"` ]; then echo SSID \"$1\" not found; exit 1; fi #Disconnect current using dbus dbus-send --system --dest=com.nokia.icd \ /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true #Wait for disconnect sleep 6 #Find IAP_ID from SSID IAP_ID=`gconftool-2 -R /system/osso/connectivity/IAP | tac | \ awk "/name = $1/,/connectivity\/IAP/" | \ awk -F '/|:' '/connectivity\/IAP/{ print $6}'` echo IAP ID = $IAP_ID #Connect to chosen SSID once disconnected dbus-send --system --type=method_call --dest=com.nokia.icd \ /com/nokia/icd com.nokia.icd.connect string:"$IAP_ID" uint32:0 sleep 20 LIST=`iwconfig wlan0 | awk -F":" '/ESSID/{print $2}'` echo Connected to $LIST dbus-send --type=method_call --dest=org.freedesktop.Notifications \ /org/freedesktop/Notifications \ org.freedesktop.Notifications.SystemNoteDialog \ string:"Connected to $LIST" uint32:0 string:"OK"