# ExecuteScript

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Unknown

Source code: <https://github.com/FrendsPlatform/Frends.Python/tree/main/Frends.Python.ExecuteScript>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| IsPreparationNeeded : `Boolean`  | <p>Defines whether the preparation script is needed to run before the main script.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                       |
| PreparationScriptPath : `String` | <p>Path to a script that should be run before a main script. Script can be .ps1 on Windows or .sh on Linux.</p><p>You can install here any dependencies that your main script needs (e.g. pip install -r requirements.txt; pip install numpy),</p><p>move to a specific directory to execute the main script from there (e.g. cd /home/user/scripts),</p><p>setup virtual environment (e.g. python -m venv venv; source venv/bin/activate) etc.</p><p><br>Default: <code>-</code><br>Example: <code>/path/to/script.sh</code></p> |
| ExecutionMode : `ExecutionMode`  | <p>Defines how script is provided.</p><p>Possible values:</p><ul><li><code>File</code>:</li></ul><p>Defines how script is provided.</p><ul><li><code>Inline</code>:</li></ul><p>Defines how script is provided.</p><p><br>Default: <code>1</code><br>Example: <code>File</code></p>                                                                                                                                                                                                                                               |
| ScriptPath : `String`            | <p>Path to the python script file.</p><p><br>Default: <code>-</code><br>Example: <code>/path/to/script.py</code></p>                                                                                                                                                                                                                                                                                                                                                                                                              |
| Code : `String`                  | <p>Inline python script to execute.</p><p><br>Default: <code>-</code><br>Example: <code>import sys; print(f'Hello, {sys.argv\[1]}!')</code></p>                                                                                                                                                                                                                                                                                                                                                                                   |
| Arguments : `String[]`           | <p>Arguments provided to the script.</p><p><br>Default: <code>-</code><br>Example: <code>\['MyName']</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                   |
| {% endtab %}                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

{% tab title="Parameter: Options" %}

| Name                             | Description                                                                                                                    |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| ThrowErrorOnFailure : `Boolean`  | <p>Whether to throw an error on failure.</p><p><br>Default: <code>True</code><br>Example: <code>false</code></p>               |
| ErrorMessageOnFailure : `String` | <p>Overrides the error message on failure.</p><p><br>Default: <code>-</code><br>Example: <code>Custom error message</code></p> |
| {% endtab %}                     |                                                                                                                                |

{% tab title="Result: Result" %}

| Name                      | Description                                                                                                                    |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Success : `Boolean`       | <p>Indicates if the task completed successfully.<br>Example: <code>true</code></p>                                             |
| ExitCode : `Int32`        | <p>ExitCode returned by the process. 0 indicates success.<br>Example: <code>0</code></p>                                       |
| Error : `Error`           | <p>Error that occurred during task execution.<br>Example: <code>object { string Message, Exception AdditionalInfo }</code></p> |
| StandardOutput : `String` | <p>Output written to standard output (stdout) by the process.<br>Example: <code>Hello, World!</code></p>                       |
| StandardError : `String`  | <p>Error output written to standard error (stderr) by the process.<br>Example: <code>File not found</code></p>                 |
| {% endtab %}              |                                                                                                                                |

{% tab title="Changelog" %}

## Changelog

### \[1.1.0] - 2025-12-05

#### Changed

* Add more specific error message when python is not installed or not found in PATH.

### \[1.0.0] - 2025-09-11

#### Changed

* Initial implementation
  {% endtab %}
  {% endtabs %}
