How to detect network change (unplugging/plugging cable)?
Save this script as an application and set it to run on startup. It will use some memory but the script is very light. You can delay even more. Mind that this routine will keep detecting the cable forever, so you must set other conditions inside your script to do what you need and stop until something changes.



on run {input}
    repeat
        set input to do shell script "ifconfig -a" as text
        set status to offset of "status:" in input
        set the_starting_point to status + 0
        set the_ending_point to status + 13
        set isCableConnected to characters the_starting_point thru the_ending_point of input as string
        if isCableConnected is "status: active" then
            display dialog "Ethernet On"
        else
            display dialog "Cable Unplugged"
        end if
        delay 1
    end repeat
end run