<ac:structured-macro ac:name="table-plus" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="applyColStyleToCell">true</ac:parameter>
<ac:parameter ac:name="heading">0</ac:parameter>
<ac:parameter ac:name="columnTypes">s,s,s,s</ac:parameter>
<ac:parameter ac:name="multiple">false</ac:parameter>
<ac:parameter ac:name="columnAttributes">style="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold,</ac:parameter>
<ac:parameter ac:name="enableSorting">false</ac:parameter>
<ac:rich-text-body>
<table data-layout="default">
<colgroup>
<col style="width: 76.0px;" />
<col style="width: 278.0px;" />
<col style="width: 106.0px;" />
<col style="width: 266.0px;" />
</colgroup>
<tbody>
<tr>
<td>
<p><strong>Syntax</strong></p>
</td>
<td>
<p>system(command)</p>
</td>
<td>
<p><strong>Package</strong></p>
</td>
<td>
<p></p>
</td>
</tr>
<tr>
<td>
<p><strong>Alias</strong></p>
</td>
<td>
<p></p>
</td>
<td>
<p><strong>Pkg Usage</strong></p>
</td>
<td>
<p></p>
</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<h2>Description</h2>
<p><ac:structured-macro ac:name="excerpt" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="hidden">true</ac:parameter>
<ac:rich-text-body>
Executes the command of the operating system.
</ac:rich-text-body>
</ac:structured-macro>
<p>Executes the command of the operating system. Returns the exit code of the program and the output and error streams as strings. Through this you may integrate outside scripts (sh, ksh, perl,...) with Jira. Streams are limited to 4Kb (only the first 4Kb are taken into account).</p></p>
<h2>Parameters</h2>
<table data-layout="default">
<colgroup>
<col style="width: 170.0px;" />
<col style="width: 97.0px;" />
<col style="width: 108.0px;" />
<col style="width: 305.0px;" />
</colgroup>
<tbody>
<tr>
<th>
<p>Parameter name</p>
</th>
<th>
<p>Type</p>
</th>
<th>
<p>Required</p>
</th>
<th>
<p>Description</p>
</th>
</tr>
<tr>
<td>
<p>command</p>
</td>
<td>
<p>String</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Valid Operating System command.</p>
</td>
</tr>
</tbody></table>
<h2>Return Type</h2>
<p><strong>String []</strong></p>
<p>returnNote</p>
<h2>Examples</h2>
<p>Let's create a file using system routine and windows command prompt:</p>
<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATA[string testfolder="c:/tests"; //assuming that folder 'tests' has been already created in c:\ path
system("C:/WINDOWS/system32/cmd.exe /c echo return true;> " + testfolder + "qqq.sil"); // you can run here any other program or custom script]]>
</ac:plain-text-body>
</ac:structured-macro>
<p>Let's invoke a windows.bat script file using system routine:</p>
<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATA[string testfolder="c: /tests /"; //assuming this path exists. //we assume in this path a file called `myexec.bat` has been previously created and contains one line `echo Hello;`
//now the following call will return `0.0|THE_PATH_OF_EXECUTION>echo Hello; Hello;|` return system ("C:/WINDOWS/system32/cmd.exe /c " + testfolder + "myexec.bat" );]]>
</ac:plain-text-body>
</ac:structured-macro>
<h2>Note</h2>
<p><ac:structured-macro ac:name="note" ac:schema-version="1">
<ac:rich-text-body>
<p>For windows operating system, you should put the full (absolute) path of the command.</p>
</ac:rich-text-body>
</ac:structured-macro></p>
<p><ac:structured-macro ac:name="info" ac:schema-version="1">
<ac:rich-text-body>
</ac:rich-text-body>
</ac:structured-macro></p>
<h2>See also</h2>
<p><ac:structured-macro ac:name="contentbylabel" ac:schema-version="3">
<ac:parameter ac:name="showLabels">false</ac:parameter>
<ac:parameter ac:name="max">25</ac:parameter
<ac:parameter ac:name="showSpace">false</ac:parameter>
<ac:parameter ac:name="cql">label = "system_routines" and space = currentSpace ( )</ac:parameter>
<ac:parameter ac:name="labels">array_routines</ac:parameter>
</ac:structured-macro>
Availability
This routine is available starting with katl-commons 1.0.
Not available on cloud.
Syntax
system(command)
Description
Executes the command command of the operating system.Returns the exit code of the program and the output and error streams as strings. Through this you may integrate outside scripts (sh, ksh, perl, ...) with Jira. Streams are limited to 4Kb (only the first 4Kb are taken into account).
Parameters
Parameter name | Type | Required | Description |
---|---|---|---|
command | string | yes | Valid Operating System command. |
Returns
string []
The routine returns an array with 3 elements in such order:
- The operating system exit code of the process being spawned (as string)
- The output stream (limited to 4Kb) as a string
- The error stream (limited to 4Kb) as a string
Example
Let's create a file using system routine and windows command prompt:
string testfolder="c:/tests"; //assuming that foler `tests` has been already created in c:\ path system("C:/WINDOWS/system32/cmd.exe /c echo return true; > " + testfolder + "qqq.sil"); // you can run here any other program or custom script
Let's invoke a windows .bat script file using system routine:
string testfolder="c:/tests/"; //assuming this path exists. //we assume in this path a file called `myexec.bat` has been previously created and contains one line `echo Hello;` //now the following call will return `0.0|[THE_PATH_OF_EXECUTION]>echo Hello; Hello;|` return system("C:/WINDOWS/system32/cmd.exe /c " + testfolder + "myexec.bat");
For windows operating system, you should put the full (absolute) path of the command.
See also