This is a simple handler to check the network connection. It works with both Ethernet and WiFi connections.
Adjust the values in the first two lines if necessary.
property primaryEthernetDevice : "en0"
property primaryWiFiDevice : "en2"
property myIPAddress : "192.168.1.10"
property mySSID : "mySSID"
set {isConnected, IPAddress, ssid} to checkConnection()
if isConnected and ssid is mySSID then
mount volume "smb://(IP)/(Drive)" as user name "(user)"
end if
on checkConnection()
set wiredIP to do shell script "/sbin/ifconfig " & primaryEthernetDevice & " | /usr/bin/awk '/inet / {print $2}'"
if wiredIP is not "" then return {true, wiredIP, ""}
set wirelessIP to do shell script "/sbin/ifconfig " & primaryWiFiDevice & " | /usr/bin/awk '/inet / {print $2}'"
if wirelessIP is not "" then
set ssid to do shell script "/usr/sbin/networksetup -getairportnetwork " & primaryWiFiDevice & " | sed 's/Current Wi-Fi Network: //g'"
return {true, wirelessIP, ssid}
else
return {false, "", ""}
end if
end checkConnection