Jump to content

Incomplete Info on External Scripts


rounak

Recommended Posts

I lost a considerable amount of time trying to run an applescript. This text below should clearly mention what kind of external scripts are supported. Any ideas how to run applescripts but keep them in an external file?

External Scripts

If you select the language as "external script", you can run an external script. If you don't specify an absolute path, Alfred will look relative to the workflow's folder. Ensure that you have the script's execute permission set.

Edited by rounak
Link to comment

External Script assumes you have an executable script or program that can be run directly (i.e. you can run it in a shell with /path/to/MyScript.py and don't need to pass it to another program, such as /usr/bin/python /path/to/MyScript.py).
 
You can't do that with compiled AppleScripts (i.e. with .scpt extension). They have to be passed to /usr/bin/osascript.
 
There are two options (I'd recommend the second):

  • Make a directly-callable script. To do this, save the script in Text format (i.e. with extension .applescript), and use the shebang #!/usr/bin/osascript as its first line. Then run chmod +x MyScript.applescript to make it executable. Easiest way is to let Alfred create the file for you (it will set the executable bit for you). But remember to use the extension .applescript, to force Text format.
  • Use the "traditional" method, and treat Alfred's Script box like a shell command line. Leave the Language set to /bin/bash, then call your script as you would from the command line: /usr/bin/osascript MyScript.scpt

I say the second is better because it runs the compiled AppleScript, which should run faster.
 
Does that help?

Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...