Hello,
I am currently attempting to write a script to patch a Mac computer.
This is my script:
#!/bin/bash
todayDate=$(date "+%d.%m.%Y")
patchingLogFile=patching_"$todayDate"
exec > /tmp/"$patchingLogFile".txt 2>&1
echo "Part 1:0 log file has been created"
computerMacOSVersionFirstValue=$( sw_vers -productVersion | /usr/bin/cut -d. -f1 )
macOSVersionUpdate="11.7.2"
if [ "$computerMacOSVersionFirstValue" == "11" ] ; then
softwareupdate -R --fetch-full-installer --full-installer-version 'macOS $macOSVersionUpdate' 2>&1
else
echo "Don't do the update"
fi
The problem I am getting, is that when I look in the log file, I get this return:
Scanning for macOS $macOSVersionUpdate installer
Install failed with error: Update not found
But if I run the code:
softwareupdate -R --fetch-full-installer --full-installer-version 'macOS 11.7.2' 2>&1Then the computer will update with the intended version.
I don't know what I am doing wrong! Can a scripting guru help me please? That would be greatly appreciated.
Thank you
