Closed master-vodawagner closed 4 years ago
Hi @master-vodawagner - Could you put an echo
before the line that starts with launchctl asuser
in the script, run on one of your affected Macs, and let me know what output you see? I'm interested in what command is actually running that would cause an "end of script" error.
Sorry my coding is basic atm, would the below work for what you need?
echo "launchctl asuser "$(USER_ID)" osascript -e "tell application \"System Events\" to shutdown""
Sort of. In the current master branch, the line you'd want to prefix with echo
is 238. That would look like this:
echo launchctl asuser "$USER_ID" osascript -e "tell application \"System Events\" to $1"
Making that change and re-running the script on an affected Mac should allow us to see what user ID and AppleScript syntax is being used.
Tue Jan 14 21:57:45 GMT 2020: Attempting a "soft" shutdown... launchctl asuser 502 osascript -e tell application "System Events" to shutdown Tue Jan 14 21:57:45 GMT 2020: Waiting 5 minutes before forcing a "hard" shutdown
If I run that command manually it errors out
X1900345:~ root# launchctl asuser 502 osascript -e tell application "System Events" to shutdown 4:4: syntax error: Expected expression but found end of script. (-2741)
Would these be a better idea than the tell command?
Line 238
if [[ "$1" = "restart" ]]; then
shutdown -r
elif [[ "$1" = "shutdown" ]]; then
shutdown -h
fi
Line 261
if [[ "$1" = "restart" ]]; then
shutdown -r now
elif [[ "$1" = "shutdown" ]]; then
shutdown -h now
fi
# Mac should restart/shutdown now, ending this script and installing updates.
Hi @master-vodawagner - Could you try again with the latest master branch? You can download the current master here. We've made a couple changes since you reported the issue, and the "Expected expression but found end of script" error makes me think you were missing a piece of the code.
Regarding the soft/hard shutdowns, I think shutdown -r
and shutdown -h
is unnecessarily rough, and haven't heard of any reports of the script failing to hard-restart after the delay passes. The kill -9
that runs just prior to the restart/shutdown should alleviate issues with most stuck processes.
@homebysix - I am on you latest version 2.3.3
@master-vodawagner Are you making any changes to the script? Haven't heard any reports of this happening with the vanilla payload as provided in our releases. Also recommend trying again with the latest build (v2.3.4), which addresses an issue that was preventing the restart/shutdown step from completing. Thanks!
Hi,
I keep getting the following error when the script attempts the soft restart commands launchctl asuser "$USER_ID" osascript -e "tell application \"System Events\" to restart"
syntax error: Expected end of line but found end of script. (-2741)