Bash Script to Auto-Update (and reboot) all Updates to Mavericks & Yosemite?
how about just

sudo softwareupdate -i -a
sudo reboot


by the way, about the script you posted, try adding sudo in front of commands below:

/usr/bin/touch /var/db/.SoftwareUpdateAtLogout
/bin/chmod og-r /var/db/.SoftwareUpdateAtLogout
/usr/libexec/PListBuddy -c "Add -RootInstallMode STRING YES" /var/db/.SoftwareUpdateOptions
/usr/libexec/PListBuddy -c "Add -SkipConfirm STRING YES" /var/db/.SoftwareUpdateOptions
/bin/chmod og-r /var/db/.SoftwareUpdateOptions