Posted on 10-17-2012 12:58 PM
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
Solved! Go to Solution.
Posted on 10-17-2012 01:07 PM
Try,
#!/bin/sh
Kind=system_profiler SPHardwareDataType | grep "Model Name" | awk '{ print $3" "$4}'
echo "<result>$Kind</result>"
Thanks & Regards,
Karthikeyan M
Posted on 10-17-2012 01:05 PM
is the first part of the result always going to be "Model Name:"?
Posted on 10-17-2012 01:07 PM
Try,
#!/bin/sh
Kind=system_profiler SPHardwareDataType | grep "Model Name" | awk '{ print $3" "$4}'
echo "<result>$Kind</result>"
Thanks & Regards,
Karthikeyan M
Posted on 10-17-2012 02:09 PM
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
Posted on 10-18-2012 12:38 PM
Perfect. Thank you Karthikeyan!!!
Posted on 10-18-2012 02:07 PM
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.