AppleScript execution error: No user interaction allowed. (-1713)

AppleScript is a powerful tool. What I love the most is the ease with which you can do most of the work. Most of my AppleScripts either ran directly from the AppleScript Editor or ran as an application.

Recently I had to write an AppleScript to run from an installer created using Izpack and unfortunately IzPack treated AppleScript files as binary file. So I had to write a shell script to start my AppleScript.

I basically had a shell script which would in-turn call my AppleScript

osascript SOURCE_LOCATION/myScript.scpt

When my script tried to show a dialog I got the following error “myScript.scpt: execution error: No user interaction allowed. (-1713)” . My script would run correctly when I run it from AppleScript Editor but when I would run the script from terminal I had the problem.

On searching I realized that AppleScript doesn’t allow User-Interaction if it is run from Terminal and writing a shell script to run AppleScript was equivalent to running it from Terminal. There were two solutions to this problem.

1. I convert my script into an application.
This would solve the problem in most cases, but in my case I wanted the installer to wait for my script to complete.

2. I wrote another script to fix the issue.

on run {sourcefile}
tell application “AppleScript Runner”
do script sourcefile
end tell
end run

I called it “AppleScriptRunner.scpt” and modified my shell script to

osascript SOURCE_LOCATION/AppleScriptRunner.scpt OURCE_LOCATION/myScript.scpt

This time the error message was not shown. AppleScript Runner can be found at “/System/Library/CoreServices/AppleScript Runner.app”

Advertisements

8 thoughts on “AppleScript execution error: No user interaction allowed. (-1713)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s