This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
action:Execute_a_Shell_Script [2019/07/01 01:13] peternlewis |
action:Execute_a_Shell_Script [2019/10/07 04:37] peternlewis [Execute a Shell Script] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Execute a Shell Script ====== | ====== Execute a Shell Script ====== | ||
- | The //Execute a Shell Script// action executes a specified shell script, either from a file or from the script embedded in the action. | + | The //Execute a Shell Script// action executes a specified shell script using `/bin/sh`, either from a file or from the script embedded in the action. |
To execute the script from an external file, choose the "Execute Script File" in the choices for script location. | To execute the script from an external file, choose the "Execute Script File" in the choices for script location. | ||
Line 8: | Line 8: | ||
{{:action:execute-shell-script.png?nolink&693|}} | {{:action:execute-shell-script.png?nolink&693|}} | ||
+ | |||
+ | If the script fails, the action will fail (v9.0+), potentially aborting the macro. | ||
+ | |||
+ | If you want to use another language, or use any special kinds of shell-specific syntax, then you should specify the language using the `#!` at the front of the script. | ||
==== Using Keyboard Maestro Variables ==== | ==== Using Keyboard Maestro Variables ==== | ||
Line 74: | Line 78: | ||
If you are dealing with non-ASCII characters, you probably want to set the `LC_ALL` environment variable to UTF8, which you can do by setting the Keyboard Maestro variable `ENV_LC_ALL` to “en_US.UTF-8”. | If you are dealing with non-ASCII characters, you probably want to set the `LC_ALL` environment variable to UTF8, which you can do by setting the Keyboard Maestro variable `ENV_LC_ALL` to “en_US.UTF-8”. | ||
+ | |||
+ | By default (v9.0+), if you have not set these environment variables they will be set to UTF-8 for you. | ||
==== Action Gear ==== | ==== Action Gear ==== | ||
- | The Action (gear) menu includes the following options: | + | The action (gear) ⚙ menu includes the following options: |
* Trim Results — removes white space from the start and end of the scripts results. | * Trim Results — removes white space from the start and end of the scripts results. | ||
Line 94: | Line 100: | ||
* Pasted in to the current selection. | * Pasted in to the current selection. | ||
* Saved to a variable. | * Saved to a variable. | ||
+ | * Appended to a variable (v9.0+). | ||
* Saved to the system or a Named Clipboard. | * Saved to the system or a Named Clipboard. | ||
* Asynchronously ignored — the action runs while the macro continues on. | * Asynchronously ignored — the action runs while the macro continues on. |