#!/bin/bash #get current ssid LIST=$(iwconfig wlan0 | awk -F":" '/ESSID/{print $2}') #if already connected then quit if [ $LIST = '"nasa"' ]; then exit 1; fi #clear previous ssid scans rm /home/user/MyDocs/scripts/scans #if not connected, bring up wlan (if not already) and scan ssids ifconfig wlan0 up SCANS=$(iwlist wlan0 scan | awk -F":" '/ESSID/{print $2}') echo "$SCANS" > /home/user/MyDocs/scripts/scans GOAL=$(more scans | awk '/"nasa"/{print "1"}' /home/user/MyDocs/scans) #if network not found, exit [ "$GOAL" ] || exit #if network found, disconnect current network and connect to network using dbus if [ "$GOAL" ]; then dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true sleep 5 dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:5f027850-3445-4eef-ac3f-76b423515990 uint32:0 fi