hsyihao 发表于 2008-6-21 12:45:14

谁能帮忙解说下谢谢了

#! /bin/bash

DEFAULT_LAN="xxx.xxx.xxx.xxx/26"

LAN="$1"
[[ -z "$LAN" ]] && LAN="$DEFAULT_LAN"

if (( UID != 0 )); then
echo "root privilege to get mac"
exit 1
fi

## just scan ...
scan_lan()
{
nmap -n -sP "$LAN"
}

## get ip mac
get_ipmac()
{
awk '{
if ( $1 ~ /^Host/ ) {
ip = $2;
}
else if ( $1 ~ /^MAC/ ) {
mac = $3;
print ip, mac;
}
}'
}

#-------------------- main --------------------

scan_lan |
get_ipmac

尽可能说祥细点谢谢了```
页: [1]
查看完整版本: 谁能帮忙解说下谢谢了