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?

  • It might be useful if you added what exactly PowerCloud does. Although it may not support OS X, a better idea of what your trying to achieve may allow someone to offer a work around. – Mort Mar 11 '13 at 18:23

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

  1. Testing connectivity.
  2. 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...


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

# Assuming all APs use the same pass code

# List of APs
'NetFasteR WLAN 3'
'WiFi HRC7dE'

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

# IP address to target

# Which AP in the list to attempt next

# 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 >/dev/null 2>&1 || break

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

      # Wait # secs before testing again.
      sleep 2

   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=$(( $myAPnum + 1 ))

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

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

     # Wait for DHCP etc...
     sleep 2 

     echo "Failed :("

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .