Posted on 08-20-2014 10:27 AM
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
Solved! Go to Solution.
Posted on 08-20-2014 11:43 AM
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>"
Posted on 08-20-2014 10:41 AM
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
Posted on 08-20-2014 11:12 AM
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.
Posted on 08-20-2014 11:20 AM
Post your script.
Posted on 08-20-2014 11:28 AM
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.
Posted on 08-20-2014 11:35 AM
#!/bin/sh
version= defaults read /System/Library/CoreServices/Screen Sharing.app/Contents/Info.plist CFBundleShortVersionString
echo "<result>$version</result>"
Posted on 08-20-2014 11:42 AM
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>"
Posted on 08-20-2014 11:43 AM
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>"
Posted on 08-20-2014 11:56 AM
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.
Posted on 08-20-2014 11:56 AM
Thank you, it wasn't working first but then I realized I had set the data type to "string" instead of "integer"
Posted on 08-20-2014 12:01 PM
@mm2270 But yours provided better detail...
Posted on 08-20-2014 12:12 PM
You both helped a lot, thanks!