HOW TO: map drives if on correct SSID

Discussion in 'Mac Programming' started by anton1s, Sep 1, 2012.

  1. anton1s, Sep 1, 2012
    Last edited: Sep 1, 2012

    anton1s macrumors member


    Jun 17, 2012
    Hi All

    What i am trying to achieve is to map external drives from my NAS only when my MBA is connected on a specific SSID

    I found few scripts that check the SSID and I have the relevant applescript. There is a variable you can use with automator but this is only to display the IP and not the current SSID.

    The way I have it so far is (Automator application is called MapDrives):

    1) pause 7 seconds
    2)Get value of variable (IP)
    3)Run Applescript below (the script needs tweaking)

    on run {input, parameters}
    	set tIP to do shell script "ifconfig en0|grep 'inet '|cut -d ' ' -f 2"
    	if (tIP as text) is not equal to "<ip address of my MBA>" then
    		tell application "MapDrives" to quit
    	end if
    end run
    4) Get Specified servers
    5)Connect to servers

    What I also need to check if the drives are already mapped then not to proceed with the script?
  2. aspacelot macrumors newbie

    Feb 11, 2013
    Any Luck?

    You have any luck on this yet? This is EXACTLY what i'm looking for. Additionally, I'd like to be able to leave my MBA set to get ip via DHCP everywhere except when I'm on network with SSID _____.
  3. Sayer macrumors 6502a


    Jan 4, 2002
    Austin, TX
    In the Network control panel you can create a "Location" based on the current settings. I believe you can get the behavior you want by simply making a new location when connected to a specific SSID.

    I am not sure how you can trigger other things when that SSID becomes available, which is done by triggering the particular "Location" setting(s). If your script runs itself it can check the location and only do its work when needed.

    Google "AppleScript Locations" for samples.

Share This Page