Skip to main content
Solved

Need Ext. Attribute for model name


Forum|alt.badge.img+14
  • Honored Contributor
  • 351 replies

Our inventory peeps aren't happy with the fact that Casper displays each model name exactly how Apple names it..

Meaning, they don't like "MacBook Pro (Mid 2012)"

They just want it to say "MacBook Pro" or "MacBook Air"

I've got the follwing ext. attribute that sort of does the trick:

#!/bin/sh
Kind=system_profiler SPHardwareDataType | grep "Model Name"
echo "<result>$Kind</result>"

However that returns the result as: Model Name: MacBook Pro And they still don't like that cuz they have to edit out "Model Name"

Does anyone have any idea how to get it to say just "MacBook Pro" ???

Thanks!!!

A

Best answer by karthikeyan_mac

Try,

#!/bin/sh
Kind=system_profiler SPHardwareDataType | grep "Model Name" | awk '{ print $3" "$4}'
echo "<result>$Kind</result>"

Thanks & Regards,
Karthikeyan M

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+10
  • Contributor
  • 161 replies
  • October 17, 2012

is the first part of the result always going to be "Model Name:"?


karthikeyan_mac
Forum|alt.badge.img+17
  • Honored Contributor
  • 281 replies
  • Answer
  • October 17, 2012

Try,

#!/bin/sh
Kind=system_profiler SPHardwareDataType | grep "Model Name" | awk '{ print $3" "$4}'
echo "<result>$Kind</result>"

Thanks & Regards,
Karthikeyan M


Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • October 17, 2012

Hey Everyone,

I did not have a lot of time to test this, so please test, test, test before putting it into production.

bash-3.2$ system_profiler SPHardwareDataType | awk '/Model Identifier:/ { print $3 }' | sed 's/[0,-9]*//g'
MacBookPro

That strips out the numbers and comma.

Thanks,
Tom


Forum|alt.badge.img+14
  • Author
  • Honored Contributor
  • 351 replies
  • October 18, 2012

Perfect. Thank you Karthikeyan!!!


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • October 18, 2012

Though the output isn't as "pretty", there is a somewhat faster way to get this info in an EA. I don't like using 'system_profiler' unless absolutely necessary because its a bit slow. We have so many EA's in our inventory that I'm constantly looking for ways to make the scripts more efficient to reduce inventory time.

You can try this-

#!/bin/sh

Model=`ioreg -c IOPlatformExpertDevice | grep MacBook | awk -F"= " '/model/{ print $2 }' | sed -e 's/^..//;s/..$//;s/[0,-9]*//g'`

echo "<result>$Model</result>"

The results will look like-

MacBookPro
MacBookAir
Macmini
MacPro
iMac

etc, so as I said, not as readable, but still useful.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings