How to check if the arduino ethernet shield has a cable connected or not.

I've done this in the past. It worked to a degree, but this is a tricky area
Some pseudo-code in here - as it refers to project specific variables...

Call this when you initially startup, and again later if the network fails for any reason, call it again

bool usingDHCP, weWantoUseDHCP;
bool networkAvailable = false;

//==================================================
bool connect_to_network(void) {
//==================================================
  networkAvailable = false;
  usingDHCP = false; // assume the worst
  if (weWantoUseDHCP) {
    Serial.print("DHCP... ");
    // DHCP timeout is set in Dhcp.h - note uppercase D
    if (Ethernet.begin(myMAC_address) != 0) {
      Serial.print("OK ");
      usingDHCP = true;
    } else {
      Serial.print("not responding. ");
    }
  }


  if (!usingDHCP) {   // DHCP not in use, or failed to init
    Serial.print("Use STATIC IP... ");
    Ethernet.begin( myMAC_address, mySTATIC_IP, mySTATIC_NS, mySTATIC_GW, mySTATIC_NM);
  }
  networkAvailable = true;
  return true;
}