Custom Script to trigger output when WAN successfully ON

Hi,

Is anyone have example of custom script to trigger an output to turn on the LED when WAN connection (remotely access) is established?