Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some short applescripts that I want to use as utility functions inside shell scripts-- for example, one returns the name of the frontmost application. The scripts reside in a personal scripts directory that is on my $path. When in another directory, I can just run


And, because the scripts directory is on the path, this file will be found and executed (at the top is #!/usr/bin/env osascript). However, when I run


To try and run the compiled version, I get:

zsh: exec format error: get_front_app_name.scpt

I would like to use the compiled version but would also like to be able to run these like any executable on my $path, that is, without having to specify the interpreter name (osacompile) or the path to the file. As of now, the only way I can see to execute the compiled .scpt applescript is to do both:

$osascript path/to/myscript.scpt

Is it possible to run the compiled form without this baggage?

share|improve this question

Since .scpt are not executable you won't be able to do this.

The shebang (!#) is not in the AppleScript syntax and therefore it won't do anything.

share|improve this answer
Applescript shebang is : #!/usr/bin/osascript – markhunte Nov 6 '13 at 12:18
That's not an Applescript, that's a shell script starting an AppleScript. – Matthieu Riegler Nov 6 '13 at 12:19
But you can use it in a compiled applescript and plain text file. It allows you to run any Applescript using it's native syntax. But yes it will not run without the osascript command. P.S I marked you back up was trigger happy. – markhunte Nov 6 '13 at 12:23
In a compiled AppleScript ? How would you do that ? Adding it to the AppleScript ByteCode just messes up the file. – Matthieu Riegler Nov 6 '13 at 12:27
No. I am incorrect. You are right the shebang is not for compiled Applescript just the plain text un compiled form to allow the script to use native applescript and as a shell scriptI knew this and was just being thick. – markhunte Nov 6 '13 at 12:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.