Creating Smart Group to sort by Screen Sharing Version

michaelherrick
New Contributor III

Hi everyone,

I am having issues Screen Sharing incompatibility between my workstation and user's workstations preventing Casper Remote from working properly. For example, my Screen Sharing version is 1.5 and it wont connect to a user with 1.4 . I'd like to make a smart group to get a definitive list of who has what version of Screen Sharing in order to aid my troubleshooting, but I cant find a way to sort by the version number for Screen Sharing since it doesn't live in /Applications .I tried the method linked here https://discussions.apple.com/thread/3445128?tstart=0
, but it doesn't work since system/library/coreservices isn't indexed by spotlight. Does anyone have any other ideas?

Thanks,

-Mike

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

The entire defaults command must be enclosed either by back ticks or using the $(..) syntax. Meaning one of these-

version=`defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString`
version=$(defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString)

I personally always prefer the latter $(command) syntax, but either one will work, so its up to you. The way you have it now is not actually setting up the variable, which is why it returns as blank.

Just one more note. For something as simple as this, you actually don't even need to assign a variable. Since ScreenSharing.app should exist on almost any Mac unless its running an extremely old OS, something like this would also work-

#!/bin/sh

echo "<result>$(defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString)</result>"

View solution in original post

11 REPLIES 11

jacob_salmela
Contributor II

You could make an extension attribute for the version number with a command like this:

defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString

michaelherrick
New Contributor III

The command works when I run it in Terminal on a machine and returns the version number, but when I create an extension attribute using that command it always returns as blank.

jacob_salmela
Contributor II

Post your script.

mm2270
Legendary Contributor III

Extension Attributes must echo back any result within <result></result> tags or you get a blank result.. In other words, like this-

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

Jacob's command above was only an example of what to use, not a full Extension Attribute script.

michaelherrick
New Contributor III
#!/bin/sh
version= defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString
echo "<result>$version</result>"

jacob_salmela
Contributor II

Close. Your script needs to store the variable as the output of the command. You can do so by putting in between a $ and two parentheses:

#!/bin/sh
version=$(defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString)
echo "<result>$version</result>"

mm2270
Legendary Contributor III

The entire defaults command must be enclosed either by back ticks or using the $(..) syntax. Meaning one of these-

version=`defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString`
version=$(defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString)

I personally always prefer the latter $(command) syntax, but either one will work, so its up to you. The way you have it now is not actually setting up the variable, which is why it returns as blank.

Just one more note. For something as simple as this, you actually don't even need to assign a variable. Since ScreenSharing.app should exist on almost any Mac unless its running an extremely old OS, something like this would also work-

#!/bin/sh

echo "<result>$(defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString)</result>"

mm2270
Legendary Contributor III

To be fair, you should probably mark Jacob's response as the answer, because he provided the defaults command to get the version string. All I did was clear up confusion on how to build an EA script.

michaelherrick
New Contributor III

Thank you, it wasn't working first but then I realized I had set the data type to "string" instead of "integer"

jacob_salmela
Contributor II

@mm2270 But yours provided better detail...

michaelherrick
New Contributor III

You both helped a lot, thanks!