Kod: Markera allt
#! /bin/bash
#
#
#####################################################################
#
function usage {
cat << EOD
usage: eth [-b]
-b Brief, just print the name of the ethernet device.
EOD
exit
}
#
#####################################################################
#
TEMP=`getopt -ob --long help,brief -n $(basename $0) -- "$@"`
if [[ $? -ne 0 ]]; then
usage
fi
eval set -- "$TEMP"
BRIEF=false
CMDNAME=$(basename $0)
while true; do
case $1 in
-h|--help)
usage
exit
;;
-b|--brief)
BRIEF=true
shift
;;
--)
shift
break
;;
*)
echo "-Got a star... [$1]"
exit
;;
esac
done
P1=$1
P2=$2
P3=$3
P4=$4
#
#echo "P1: $P1"
#echo "P2: $P2"
#echo "P3: $P3"
#echo "P4: $P4"
#echo "Param: $param"
#
#####################################################################
#
#ETH=$(LANG=C; nmcli d | grep "connected" | grep -v "disconnected" | awk '{ print $1 }')
#echo "ETH: $ETH"
ETHDEVS=$(lshw -short -c network | tail +3 | awk '{ print $2 }')
for ETH in $ETHDEVS; do
#echo
LINK=$(LANG=C; ethtool $ETH 2> /dev/null | grep "Link detected" | awk '{ print $3 }')
if [[ $LINK == "yes" ]]; then
if [[ $BRIEF == true ]]; then
echo $ETH
else
echo
#echo "$ETH - $LINK"
ifconfig $ETH
fi
fi
done
#echo