Extension Attribute: Has Extension Attribute?

bentoms
Release Candidate Programs Tester

Hi guys,

Just updated my Extension Attribute that reports back if the mac has an Extension Attribute card installed.

code below, & updated my blog:  http://wp.me/p12A66-32

#!/bin/sh

checkHasAnAirportCard=networksetup -listallhardwareports | grep "Hardware Port: Air" | cut -c 16-
checkHasWiFi=networksetup -listallhardwareports | grep "Hardware Port: Wi-" | cut -c 16-
if [[ -z "$checkHasAnAirportCard" && -z "$checkHasWiFi"  ]]; then
echo "<result>No</result>"
else
echo "<result>Yes</result>"
fi

1 REPLY 1

bentoms
Release Candidate Programs Tester

Apologies for the weird subject.. should have read: Extension Attribute: Has Airport/Wi-Fi?

Anyway, Walter pointed out a much more elegant solution using egrep:

#!/bin/sh

checkWireless=$(networksetup -listallhardwareports | egrep "Hardware Port: (Air|Wi)" | cut -c 16-)
if [ -n "${checkWireless}" ]; then
    echo "<result>Yes</result>"
else
    echo "<result>No</result>"
fi