1

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

$myscript.applescript

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

$myscript.scpt

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?

1 Answer 1

1

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.

6
  • Applescript shebang is : #!/usr/bin/osascript
    – markhunte
    Commented Nov 6, 2013 at 12:18
  • That's not an Applescript, that's a shell script starting an AppleScript. Commented Nov 6, 2013 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
    Commented Nov 6, 2013 at 12:23
  • In a compiled AppleScript ? How would you do that ? Adding it to the AppleScript ByteCode just messes up the file. Commented Nov 6, 2013 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
    Commented Nov 6, 2013 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .