- Difficulty level: easy
- Time need to lean: 10 minutes or less
- Key points:
- Action
run
usesbash
under linux andbatch
under windows - Other shell scripting actions calls respective shells
- Action
run
is the most frequently used action in sos. In most cases, it is similar to action bash
and uses bash
to execute specified script. Under the hood, this action is quite different from bash
because the run action does not have a default interpreter and would behave differently under different situations.
In the simplest case when one or more commands are specified, action run
would assume it is a batch script under windows, and a bash script otherwise.
It is different from an bash
action in that
- It will print the commands that re executed before execute
- It will exit with error if any of the commands exits with non-zero code
For example, whereas a bash
action would print an error message but continue as follows
The run
action would exit with error
In another word,
run:
command1
command2
command3
is equivalent to
bash:
command1 && command2 && command3
under Linux/MacOS systems.
If the script starts with a shebang line, this action would execute the script directly. This allows you to execute any script in any language. For example, the following script executes a python script using action run
and the following example runs a complete sos script using command sos-runner
Note that action run
would not analyze shebang line of a script if it is executed in a docker container (with option docker-image
) and would always assumed to be bash
.
Execute script with a sh
interpreter. On most systems it is just an alias to bash
.
Action csh
executes specified script with a csh
interpreter
Action tcsh
executes specified script with a tcsh
interpreter
Action zsh
executes script with a zsh
interpreter
refer to script actions for detail