Skip to main content

I am trying to create an Extension Attribute that will show the attached thunderbolt display's SN#. I know how to get the info from the command line using /usr/sbin/system_profiler | grep "Display Serial Number"

I have tried to create the Extension Attribute with no luck. Below is what I am using and it is just returning result and the SN.

Thanks

RIchard

#!/bin/sh

result=/usr/sbin/system_profiler | grep "Display Serial Number"

echo "<result>result</result>"

Looks like you're forgetting a dollar sign for the $result variable.
On 11/30/11 6:07 PM, "San Fran Geek" <sanfrangeek at gmail.com> wrote:

--

William Smith
Technical Analyst
Saint Paul, MN
(651) 632-1492


This has worked for us....

-----------

#!/bin/sh

echo "<result>$(system_profiler SPDisplaysDataType |grep "Display Serial
Number" |awk '{print $4}')</result>"

Thanks,
Brian


Using the above as an example I'm really interested in an extension attribute that will actually list the output of "system_profiler SPDisplaysDataType" but playing around with greps output, removing grep altogether, etc is producing skewed results in terminal and no results in EA in Casper.

I'm learning as I go with scripting as this was never a big part of my previous job so I've been McGyver'ing scripts with good results, not so much with this though, any help or idea would be appreciated.


Try this out:

system_profiler SPDisplaysDataType | grep -e "^ {8}[A-Z]" -e "Display Serial Number" | sed 's/^[ ]*//' | sed -e :a -e '$!N;s/ Display Serial Number: / /;ta' -e 'P;D'

If you want to add to it:

system_profiler SPDisplaysDataType | grep -e "^ {8}[A-Z]" -e "Display Serial Number" -e "Main Display" | sed 's/^[ ]*//' | sed -e :a -e '$!N;s/ Display Serial Number: / /;ta' -e '$!N;s/ Main Display/ Main Display/;ta' -e 'P;D'


@sean

Thats amazing. There is no way in hell I would've ever got to that as being my end result of trying to figure this out.

Dumping that in to terminal or creating shell script and running it locally works 100% but putting that into Casper as an extension attribute is still no bueno, is there anything i'm missing?

#!/bin/sh

result=`system_profiler SPDisplaysDataType | grep -e "^ {8}[A-Z]" -e "Display Serial Number" | sed 's/^[ 	]*//' | sed -e :a -e '$!N;s/
Display Serial Number: / /;ta' -e 'P;D'`

echo "$result"

Does it needs to be line separated for casper to recognize it? Terminal doesn't seem to mind copying/pasting that in directly. Sorry for hi-jacking @rdagel's thread, hopefully there's other casper users out there that will find this informative.


The result has to be a tag

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


derp.

thanks @sean, in all previous attempts i had my tags but for whatever reason decided they were useless this go around. much appreciated.