> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/components/system/execute.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
