You can use the following command to know if the Ethernet cable is plugged or not:
If the Ethernet cable is unplugged you will get a 0 and if it is plugged you will get a 1.
I have not tested it yet but the idea I can think is to polling the state of this flag in order to know if the cable is plugged or not. You can run a script in the background for that. If you want to run that script in the start-up I'd suggest checking this following thread, it might be interesting for you: Re: How to automatically run program on Intel Galileo startup?