|
#1
| |||
| |||
| 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 |
|
#2
| ||||
| ||||
| 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
__________________ 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 |
|
#3
| |||
| |||
| Thanks Brian...works great! -calvin
__________________ "A few guys with guns can ruin everything" -N Peart |
![]() |
| Thread Tools | |
|
|