Posted on 06-10-2020 05:26 AM
Hello, Jamf community.
I am trying to create a script which I can deploy via Jamf to a number of clients. The script should check the OS version and push the installation of Security Update for Safari 13.1.1. Unfortunately it returns a error " text.txt: line 15: syntax error: unexpected end of file" and i am not able to understand why is this happening.
Here is the script:
sw_vers
if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then
softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
sleep 1
exit 0
Posted on 06-10-2020 11:37 AM
I am not the expert here... but don't you need another else statement to cover all other conditions?
Posted on 06-10-2020 11:52 AM
we used softwareupdate to check and install patches on all of our devices.
Posted on 06-10-2020 11:32 PM
Why not use smart groups to scope the macOS versions you want to target and apply that to the policy?
Posted on 06-10-2020 11:37 PM
Add "fi" after "elif" and "#" before anything on first line. Should work then.
#!/bin/bash
sw_vers
if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
fi
sleep 1
exit 0
Also can't find any variable defined, so I guess this script below is something you're looking for -
#!/bin/bash
ProductVersion=$(sw_vers | grep "ProductVersion" | awk '{ print $2; }')
if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
fi
sleep 1
exit 0
Also it would be good to add "else" to get some output as well if none of defined OS versions doesn't match in if statement, e.g. -
#!/bin/bash
ProductVersion=$(sw_vers | grep "ProductVersion" | awk '{ print $2; }')
if [[ "$ProductVersion" == "10.13.6" ]]; then
softwareupdate -i 'Safari13.1.1HighSierraAuto-13.1.1'
elif [[ "$ProductVersion" == "10.14.6" ]]; then softwareupdate -i 'Safari13.1.1MojaveAuto-13.1.1'
else
echo "OS version didn't match"
fi
sleep 1
exit 0