Osascript error: AppleEvent timed out. (-1712)

beeboo
Contributor

Here is the error some of my users are getting regarding running a shell script calling osascript to prompt the user with a notification dialog box.

Error: execution error: Finder got an error: AppleEvent timed out. (-1712)

Script in question:

#!/bin/sh

alertAPP() {
    /usr/bin/osascript <<EOD
        tell application "Finder"
            activate
            set DialogTitle to "${appNAME}"     
            set DialogText to "${appNAME} will be closed within 60 seconds. 

To close ${appNAME} now, please click the 'Close Now' button otherwise ${appNAME} will automatically force close after 60 seconds."
            set DialogButton to "Close Now"
            set DialogIcon to "Library:LC:logo.icns"
            display dialog DialogText buttons {DialogButton} with title DialogTitle with icon file DialogIcon giving up after 60
        end tell
EOD
}

i have a good feeling that osascript itself is working because this is a function that is run against an array, and since i can see the name of the application in question from the array, i can at least assume that the osascript that ran to get the array data, works.

not sure why some individuals are getting this error.
do i need to set a timeout instead? if so, how would i add it to the function?

oddly enough, i do have a few straggler units that get this error:
Not authorized to send Apple events to System Events. (-1743)

but i have already pushed the PPPC profile to all my devices for terminal, osascript, system events, etc

0 REPLIES 0