Applescript and Automator Mix

Discussion in 'Mac Programming' started by anton1s, Oct 20, 2012.

  1. macrumors member

    anton1s

    Joined:
    Jun 17, 2012
    #1
    Hi All

    What I am trying to achieve is to map certain drives one my MBA is either connected to wireless with ip : 192.168.2.15 or connected via vpn with ip 10.242.5.6. Automator script is called "MapDrives"

    I am using automator and applescript for this. So far it seems to be working but I would like to know if there is a more efficient way of doing this

    Thanks

    Automator steps
    1)Pause for 7 seconds (until wireless is up)
    2)Run Applescript

    Code:
    global Local_IP
    global VPN_IP
    
    on run {input, parameters}
    	set Local_IP to do shell script "ifconfig en0|grep 'inet '|cut -d ' ' -f 2"
    	set VPN_IP to do shell script "ifconfig tun0|grep 'inet '|cut -d ' ' -f 2"
    	
    	if (Local_IP as text) is equal to "192.168.2.15" or (VPN_IP as text) is equal to "10.242.5.6" then
    	else
    		tell application "MapDrives" to quit
    	end if
    end run
    3)Get Specific servers

    Code:
    smb://<NAS ip>/<folder A>
    smb://<NAS ip>/<folder B>
    4)Connect to servers


    Also is there a way for the script to automatically run once either of the ip has change?

    Thanks
    anton1s
     

Share This Page