> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# sysExecute

> Executes a program or shell command with optional arguments, working directory, and timeout settings, returning the program's standard output and error output.

Executes a program or command.

## Required Parameters

* **name**: The name of the command or program to execute.

## Optional Parameters

* **arguments**: The space-delimited set of command-line arguments for the command or program (for example, `<arc:set attr="executable.arguments" value="arg1 arg2 arg3"/>`).
* **argarray#**: An array of arguments to supply to the command or program. The array is built by creating an `argarray#` entry for each index (argument) that you want (see the examples below).
* **directory**: The directory to start the command or program in. The default value is `.`.
* **timeout**: The maximum amount of time (in seconds) to wait for the command or program. Use `-1` to indicate no timeout. The default value is `60`.
* **waitforoutput**: Whether to wait for the output of the command or program. The default value is `true`.

## Output Attributes

* **sys:output**: The output of the command or program.
* **sys:error**: The error output, if any, of the command or program.

## Examples

### .NET

```xml theme={null}
<!-- Creating an out item to hold output data -->
<arc:set attr="out.data" value=""/>
<!-- Creating an input item, 'executable' and assigning input parameters -->
<arc:set attr="executable.name" value="C:\\temp\\foo.bat" />
<!-- Creating an array of arguments that will be passed into the command or program -->
<arc:set attr="executable.argarray#1" value="arg1"/>
<arc:set attr="executable.argarray#2" value="arg2"/>
<arc:set attr="executable.argarray#3" value="arg3"/>
<!-- Calling the operation, passing in the input item and setting an output item -->
<arc:call op="sysExecute" in="executable" out="results">
  <!-- Populating the data attribute of the out item -->
  <arc:set attr="out.data" value="[results.sys:output]" />
</arc:call>
<!-- Setting the filename of the out item and pushing it as an output file -->
<arc:set attr="out.filename" value="echo.txt"/>
<arc:push item="out"/>
```

The batch file called here is programmed to output `Hello world` along with a list of the arguments that were passed in. The output of this script (`echo.txt`) looks like this:

```
Hello world.
The first argument is arg1
The second argument is arg2
The third argument is arg3
```

### Linux

```xml theme={null}
<!-- Creating an out item to hold output data -->
<arc:set attr="out.data" value=""/>
<!-- Creating an input item, 'executable' and assigning input parameters -->
<arc:set attr="executable.name" value="bash" />
<arc:set attr="executable.arguments" value="/mnt/c/scripts/helloworld.sh lion tiger bear" />
<!-- Calling the operation, passing in the input item and setting an output item -->
<arc:call op="sysExecute" in="executable" out="results">
  <!-- Populating the data attribute of the out item -->
  <arc:set attr="out.data" value="[results.sys:output]" />
</arc:call>
<!-- Setting the filename of the out item and pushing it as an output file -->
<arc:set attr="out.filename" value="echo.txt"/>
<arc:push item="out"/>
```

The batch file called here is programmed to output `hello linux world` along with a list of the arguments that were passed in. The output of this script (`echo.txt`) looks like this:

```
hello linux world
The first argument is lion
The second argument is tiger
The third argument is bear
```
