编程知识 cdmana.com

Getting network card status by Linux

#!/bin/sh

BASEDIR="/sys/class/net"
for i in $( ls $BASEDIR ) 
do 
    if [ -L $BASEDIR/$i ]; then
        carrier=`cat $BASEDIR/$i/carrier 2>/dev/null || echo 0`
        operstate=`cat $BASEDIR/$i/operstate 2>/dev/null || echo 0`
        echo $i:$carrier:$operstate
    fi
done

 

版权声明
本文为[The moon startles magpies]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224160308902g.html

Scroll to Top