> ## 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

> プログラムまたはシェルコマンドを、オプションの引数、作業ディレクトリ、タイムアウト設定とともに実行し、プログラムの標準出力とエラー出力を返します。

プログラムまたはコマンドを実行します。

## 必要なパラメータ

* **name**：実行するコマンドまたはプログラムの名前。

## オプションのパラメータ

* **arguments**：コマンドまたはプログラムに対する、スペース区切りのコマンドライン引数のセット（例：`<arc:set attr="executable.arguments" value="arg1 arg2 arg3"/>`）。
* **argarray#**：コマンドまたはプログラムに渡す引数の配列。配列は、必要な各インデックス（引数）に対して`argarray#` エントリを作成することで構築します（以下の例を参照してください）。
* **directory**：コマンドまたはプログラムを開始するディレクトリ。デフォルト値は`.` です。
* **timeout**：コマンドまたはプログラムを待機する最大時間（秒単位）。タイムアウトなしを示すには`-1` を使用します。デフォルト値は`60` です。
* **waitforoutput**：コマンドまたはプログラムのアウトプットを待機するかどうか。デフォルト値は`true` です。

## アウトプット属性

* **sys:output**：コマンドまたはプログラムのアウトプット。
* **sys:error**：コマンドまたはプログラムのエラー出力（ある場合）。

## 例

### .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"/>
```

ここで呼び出されるバッチファイルは、`Hello world` と、渡された引数のリストを出力するようにプログラムされています。このスクリプトのアウトプット（`echo.txt`）は次のようになります：

```
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"/>
```

ここで呼び出されるバッチファイルは、`hello linux world` と、渡された引数のリストを出力するようにプログラムされています。このスクリプトのアウトプット（`echo.txt`）は次のようになります：

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