LINUX 偵測 有線網路插拔

 

 

You want to look at the nodes in

/sys/class/net/

I experimented with mine:

Wire Plugged in:

eth0/carrier:1
eth0/operstate:unknown

Wire Removed:

eth0/carrier:0
eth0/operstate:down

Wire Plugged in Again:

eth0/operstate:up
eth0/carrier:1

Side Trick: harvesting all properties at once the easy way:

grep "" eth0/*

This forms a nice list of key:value pairs.

    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()