Have OS X auto-search for WiFi My school has installed PowerCloud, which does not officially support OS X. It works sometimes, sometimes it doesn't. I've tried to narrow it down but it's impossible. I was wondering if there is a way to write an Automater/AppleScript script to connect to 1 network, and then see if it gets the ! in the WiFi symbol, and then try the next one, and then cycle. Is there a way to do this?
I would do it through a bash script instead since the Unix foundation of OSX provides all that you need and you don't have to play with the GUI which is not easy.

The two most important things are


Testing connectivity.
Force reconnection to an AP.


For the first a simple ping should be sufficient and for the second you can use the following command.

networksetup -setairportnetwork en1 "BLAH" "mypassword"

So the script would look like this...

#!/bin/sh

whotest[0]='test' || (echo 'Failure: arrays not supported in this version of bash.' &amp;&amp; exit 2)

# Assuming all APs use the same pass code
myAPpass="mypassword"

# List of APs
myAPlist=(
'NetFasteR WLAN 3'
'WiFi HRC7dE'
'BLAH'
)

myAPcount=0
while [ "x${myAPlist[myAPcount]}" != "x" ]
do
   myAPcount=$(( $myAPcount + 1 ))
done
echo "There are $myAPcount APs available."

# IP address to target
myIntIP="192.168.0.1"

# Which AP in the list to attempt next
myAPnum=0

# We'll loop forever
while true ; do

   # Monitor connection; Loop until ping fails
   while true ; do
      # Test connection. If non zero status it failed.
      ping -c 1 -t 1 $myIntIP &gt;/dev/null 2&gt;&amp;1 || break

      echo "Successfull heart beat at `date`\t\r\c"

      # Wait # secs before testing again.
      sleep 2
   done

   echo " "
   echo "Failed to contact internal IP. Reconnecting..."

   # Try to connect to an AP in the list
   while true; do
      # Get next AP in the list
      if [ $myAPnum -eq $myAPcount ] ; then
     myAPnum=0
      else
     myAPnum=$(( $myAPnum + 1 ))
      fi
      myNewAP=${myAPlist[myAPnum]}

      echo "Trying AP '$myNewAP' : \c"

      # Connect to new network
      networksetup -setairportnetwork en1 "$myNewAP" "$myAPpass" &gt;/dev/null 2&gt;&amp;1
      if [ "x$?" = "x0" ] ; then
     echo "Success!" 

     # Wait for DHCP etc...
     sleep 2 

     break
      else
     echo "Failed :("
      fi
   done
done


You will likely have to tweak it a bit to get the right delays and so forth but for me it works quite well.

If the APs don't share passwords then you will need to add a second array with them. 

If you are worried about passwords being safe, you could set it up to run as root and change the permissions so that only root can read it.

EDIT: The script is pretty dumb. It can take a while to find an AP that is working if the list is long. You can reduce delays by making it smarter. For example, you could check using the airport tool for a list of available APs and then pick one to connect to.