Im trying to run a script that is supposed to:
-This script uses the softwareupdate program on OSX to automatically check for updates and install them. It also logs all updates to the /Library/Management/update.log file.
-It first checks to see if there are any users logged in, and if so, logs the user in the log file and ends.
-If there is no user logged in, it updates the computer, logs the information, and reboots.
Here is the script:
I have tried it on 4 iMacs running 10.6.8 and 10.7.4 and I keep getting this error:
Any ideas??
-This script uses the softwareupdate program on OSX to automatically check for updates and install them. It also logs all updates to the /Library/Management/update.log file.
-It first checks to see if there are any users logged in, and if so, logs the user in the log file and ends.
-If there is no user logged in, it updates the computer, logs the information, and reboots.
Here is the script:
Code:
#!/bin/sh
users=$(users)
users1=$(echo "${#users}")
if [ $users1 -lt 1 ]
then
date >> /Library/Management/update.log && /usr/sbin/softwareupdate -aiv >> /Library/Management/update.log && /sbin/reboot
else
date >> /Library/Management/update.log && echo "Logged in users: " >> /Library/Management/update.log && echo $(users) >> /Library/Management/update.log
fi
I have tried it on 4 iMacs running 10.6.8 and 10.7.4 and I keep getting this error:
Code:
update.sh: line 9: syntax error near unexpected token `fi'
update.sh: line 9: `fi'
Any ideas??