home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / ifupdown / examples / get-mac-address.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2005-05-12  |  380 b   |  18 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. export LANG=C
  6.  
  7. iface="$1"
  8. mac=$(/sbin/ifconfig "$iface" | sed -n -e '/^.*HWaddr \([:[:xdigit:]]*\).*/{s//\1/;y/ABCDEF/abcdef/;p;q;}')
  9. which=""
  10.  
  11. while read testmac scheme; do
  12.     if [ "$which" ]; then continue; fi
  13.     if [ "$mac" = "$(echo "$testmac" | sed -e 'y/ABCDEF/abcdef/')" ]; then which="$scheme"; fi
  14. done
  15.  
  16. if [ "$which" ]; then echo $which; exit 0; fi
  17. exit 1
  18.