Application icon

Run External Script

This function is used to run a Mac OS X script.

The function operates in two modes: Script Path and Script Content.

With Script Path you supply a full patch to a script file. A full path after unescaping is required. ie. starting with a / character. It is your responsibility to write the file. If the filename extension of the script is .yatesh, Yate will set the file's attributes to ensure that it can be executed.

With Script Content, you are supplying the content for the script. Yate will automatically write the script file and delete it when it is no longer needed. You can use the control to the right of the text field to display a multi line editor.

For both modes, the text field may contain any of the escape sequences described in Escape Sequences.

Example 1: run a script by specifying the path to the script file:

Set named variable 'script content' to "script statements"
Write Text File "\?dl/script.yatesh" from named variable 'script content', encoding UTF-8 (Lossless)
Run External Script at path '\?dl/script.yatesh' () --> Variable 0

The first statement saves the script content to a named variable. The second statement writes a file to the Downloads folder. The third statement runs the script.

Example 2: run a script by specifying the content in a named variable:

Set named variable 'script content' to "script statements"
Run External Script with content "\<script content>" () --> Variable 0

The first statement saves the script content to a named variable. The second statement runs the script with the content in the named variable. Note that the content could have been placed directly in the Run External Script statement.

Example 3: run a script by specifying the content inline:

Run External Script with content "script statements" () --> Variable 0

The statement runs the script with the content inline.

Note that if the same script is to be called multiple times by an action, the Script Path mode is more efficient as the script file need only be written once. A file is saved each the Script Content mode is used.

Regardless as to which mode you use, the first line of the actual script must typically be a shebang (#!) which specifies the interpreter which should execute the script. eg:

#!/bin/sh

You can elect to have the script run only once per set of files. Note that the single result will be saved to all files when this option is specified. The Run once option is only meaningful when executing stepwise. When this option is not set, the script will be run once for every selected track when running stepwise.

If the script cannot be launched the action will be cancelled.

Error handling is controlled by options which may be interpreted differently on whether you are running batched or not.

The termination status code from the script is saved to named variable External Script Result Code.

When not running batched, if any data is written to stderr, it will be displayed in an error message. You can choose to continue or cancel. If Ignore errors is specified, an error message will not be displayed. The contents of stderr will be saved to the External Script stderr Output named variable. If no error has occurred, the named variable will be cleared.

When running batched, an error will be posted to the log file and the action will continue. If you wish to test for errors you can select the Ignore errors option.

Note that the External Script stderr Output and External Script Result Code named variables are set or cleared each time a script is run. The values may be meaningless when running stepwise if the Run once option is not set.

While intended for batched execution, the Stop action on script error option will always work and will stop immediate and/or batch processing.

The output of the script will be placed into the specified track variable.