image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old December 21st, 2003, 12:12 AM
Registered User
 
Join Date: Jan 2002
Location: San Jose
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
clc2112 is on a distinguished road
Need to get interface info from script

Im writing a getinfo shell script and need to get the number of interfaces and their MAC addresses.

This is what is generated thus far...

CPU: Single 667
DRIVE: 27.94 GB
FirmWare: 4.29f1
CD Type: CD-RW/DVD-ROM
Build: (7D24)
SerNum: QT1527ERLY1
IF Cnt: 2
MAC 1: 00:03:93:5a:ee:42
MAC 2: 00:30:65:1d:87:df
AIRPORT: Yes
Memory: 1 GB

But it really isn't obtained gracefully. I have attempted using the output from the system profiler command (then parsing it) as well as 'ifconfig -a'

if you know of a way to get this info that I can use within a shell script, please let me know.

Thanks!
Calvin
__________________
"A few guys with guns can ruin everything"
-N Peart
Reply With Quote
  #2  
Old December 21st, 2003, 10:43 AM
btoneill's Avatar
keeper of the cheese
 
Join Date: Jul 2002
Location: Minneapolis, MN
Posts: 797
Thanks: 0
Thanked 0 Times in 0 Posts
btoneill is on a distinguished road
Here you go. It ignores the loopback address, and only reports interfaces that are up.

Code:
#!/bin/sh

for x in `ifconfig -lu`; do

        if [ "X$x" != "Xlo0" ]; then
                ether=`ifconfig $x ether | grep ether | awk '{ print $2 }'`
                echo "Interface $x has mac address $ether"
        fi
 
done
Brian
__________________
UNIX is simple and coherent, but it takes a true genius (or a programmer at any rate) to understand and appreciate its simplicity -- Dennis Ritchie
Reply With Quote
  #3  
Old December 30th, 2003, 01:24 PM
Registered User
 
Join Date: Jan 2002
Location: San Jose
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
clc2112 is on a distinguished road
Thanks Brian...works great!

-calvin
__________________
"A few guys with guns can ruin everything"
-N Peart
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 09:21 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.