# Execute

Component variation of Execute function

## Component Signature

```
<bx:Execute variable=[string]
name=[string]
arguments=[any]
timeout=[long]
terminateOnTimeout=[boolean]
directory=[string]
outputFile=[string]
errorFile=[string]
errorVariable=[string]
exitCode=[string] />
```

### Attributes

| Atrribute            | Type      | Required | Description                                                                   | Default |
| -------------------- | --------- | -------- | ----------------------------------------------------------------------------- | ------- |
| `variable`           | `string`  | `false`  | The variable name to produce                                                  |         |
| `name`               | `string`  | `true`   | The process name or binary path ( e.g. bash or /bin/sh )                      |         |
| `arguments`          | `any`     | `false`  | The process arguments ( e.g. for `java --version` this would be `--version` ) |         |
| `timeout`            | `long`    | `false`  | The timeout to wait for the command, in seconds ( default unlimited )         |         |
| `terminateOnTimeout` | `boolean` | `false`  | Whether to terminate the process/command if a timeout is reached              | `false` |
| `directory`          | `string`  | `false`  | A working directory to execute the command from                               |         |
| `outputFile`         | `string`  | `false`  |                                                                               |         |
| `errorFile`          | `string`  | `false`  | An optional file path to write errors to                                      |         |
| `errorVariable`      | `string`  | `false`  | Optional variable to produce for error output                                 |         |
| `exitCode`           | `string`  | `false`  | An optional variable to set the exit code into                                |         |

## Examples

### Script syntax

If you want to execute a script (.sh,.cmd,.bat), use bash (linux) or cmd.exe (windows) as the command and the script as argument for the shell interpreter.

```java
bx:execute name="bash" arguments="/opt/jq.sh #cmdArgs#" variable="standardOut" errorVariable="errorOut" timeout="10";

```

### Script syntax with terminateOnTimeout

Printing a PDF using lpr

```java
bx:execute name="lpr" arguments="-P 'My Print Job Name' 'C:/Users/devguy/Documents/server/mynewfile.pdf'" timeout="5" terminateOnTimeout="true";

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/components/system/execute.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
