check MAC
时间:2007-04-24 来源:lalf
chkmac.sh
#!/bin/bash
#Program
#This script is used to check the mac address
#History
#2006/11/28 Lalf First release
MAC0=`ifconfig eth0 |grep "HWaddr" | awk '{print $5}'`
MACaddr0=`echo $MAC0 | awk -F ":" '{print $1 $2 $3 $4 $5 $6}'`
echo "***** Begin Check NIC0 MAC Address *****"
echo "Please Input NIC0 MAC Address:"
while [ "1" = "1" ]
do
read inputMAC0
mac_count=$(echo $inputMAC0 | wc -c)
if [ $mac_count -ne 13 ]; then
echo "****************************"
echo "* NIC0 MAC is incorrect,it should be 12 length *"
echo "* Please Input Again: *"
echo "****************************"
continue;
fi
if [ "$inputMAC0" = "$MACaddr0" -o "$inputMAC0" = "$MACaddr1" ];then
echo "NIC0 MAC Check PASS"
else
echo "NIC0 MAC Check Fail"
echo "Input $inputMAC0, but real $MACaddr0"
read fei
exit 1
fi
break;
done
#!/bin/bash
#Program
#This script is used to check the mac address
#History
#2006/11/28 Lalf First release
MAC0=`ifconfig eth0 |grep "HWaddr" | awk '{print $5}'`
MACaddr0=`echo $MAC0 | awk -F ":" '{print $1 $2 $3 $4 $5 $6}'`
echo "***** Begin Check NIC0 MAC Address *****"
echo "Please Input NIC0 MAC Address:"
while [ "1" = "1" ]
do
read inputMAC0
mac_count=$(echo $inputMAC0 | wc -c)
if [ $mac_count -ne 13 ]; then
echo "****************************"
echo "* NIC0 MAC is incorrect,it should be 12 length *"
echo "* Please Input Again: *"
echo "****************************"
continue;
fi
if [ "$inputMAC0" = "$MACaddr0" -o "$inputMAC0" = "$MACaddr1" ];then
echo "NIC0 MAC Check PASS"
else
echo "NIC0 MAC Check Fail"
echo "Input $inputMAC0, but real $MACaddr0"
read fei
exit 1
fi
break;
done
相关阅读 更多 +