Hello together,
I'm pretty new to scripting on OS X and hope that one of you can help me with this.
I have a script that is supposed to check if a certain app is installed, get its version and do something if it's not yet installed.
#!/bin/sh
echo "Checking installed version"
minVer=“2.1.0”
installedVer=`system_profiler SPApplicationsDataType | grep -B7 "McAfee Endpoint Protection for Mac" | awk '/Version/ { print $2 }'`
if [ -z "$installedVer" ]
then
echo "McAfee Endpoint Protection for Mac is not installed"
else
echo "Installed version is $installedVer"
if [ “$installedVer” == “$minVer” ]
then
echo "Installed version $installedVer is up-to-date"
exit 1
fi
fi
echo "Installing Mcafee Endpoint Protection 2.1.0"
exit 1
The script works fine when I run in in Terminal but when I execute it via Casper Remote or policy I get the following:
Sending Wake On LAN command... Opening SSH Connection to 192.168.1.15... Authenticating... Successfully authenticated. Verifying Computer's Identity... The MAC Address has been verified. Checking Operating System Version... Running Mac OS X 10.9.1 (13B42) Verifying /usr/sbin/jamf... /usr/sbin/jamf is current (9.23) Verifying /Library/Preferences/com.jamfsoftware.jamf.plist... Preparing Policy... Executing Policy 2014-02-16 at 9:24 AM | CasperAdmin| 1 Computer... Creating directory structure for /Library/Application Support/JAMF/Downloads/ Downloading http://CasperServer/CasperShare/Scripts/test.sh... Running script test.sh... Script exit code: 1 Script result: Checking installed version Installed version is 2.1.0 Installing Mcafee Endpoint Protection 2.1.0 Submitting log to https://jssserver:8443/ Finished.
As you can see, while it detects that version 2.1.0 is already installed, it still tries to install it again.
Can someone tell me what I'm doing wrong?
Thanks,
Dirk