
#ETHERNET STATUS SPEED CHANGES WHEN REPLUGGED PATCH#
Nota: This require patch to be installed. sys/class/net/eth0/* 2>/dev/null |Ĭould render something like (once you've unplugged and plugged back, depending ): +++ - 14:18:29.577094838 +0100 sys/class/net/eth0/* 2>/dev/null >ethstate This is a pooling method, not a real event tracking. Reading or writting under /syscould break your system, especially if run as root! You've been warned -) If you need something more powerful, take a look at my NCD programming language, a programming language designed for network configurations.įor example, a simple NCD script that will print "cable in" and "cable out" to stdout (assuming the interface is already up): process foo d' The problem with doing network configurations with shell scripts is that shell scripts are terrible for event handling (such as a network cable being plugged in and out). Side note: if you use rtnetlink, you have to work together with udev, or your program may get confused when udev renames a new network interface. On the low level, these events can be caught using rtnetlink sockets, without any polling.

I guess I can't put you both down as the correct answer? And its probably fair for you that I do choose one. Kent Fredric and lothar, both of your answers satisfy my need. How is the Linux world suppose to have their own version of the Windows bubble that pop up from the icon tray indicating that you've just unplugged the network cable? Isn't there some state which can be used in the /proc file system (everything else is in there)? Ping a host - since the product will be within a LAN using an unknown network configuration and unknown hosts.Using 'ifconfig' - since a network cable may be connected but the network not properly configured or not currently up.

The following solutions which have been proposed on other sites do NOT work for this purpose: In a Linux environment, I need to detect the physical connected or disconnected state of an RJ45 connector to its socket.
