Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 1


...

Info
titleAvailability

This routine is available starting with katl-commons 1.0.

Not available on cloud.

Syntax

system(command)

Description

Excerpt

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).</p></p>
<h2>Parameters</h2>
<ac:structured-macro ac:name="table-plus" ac:schema-version="1">
<ac:parameter ac:name="applyColStyleToCell">true</ac:parameter>
<ac:parameter ac:name="columnTypes">s,s,s,s</ac:parameter>
<ac:parameter ac:name="heading">0</ac:parameter>
<ac:parameter ac:name="multiple">false</ac:parameter>
<ac:parameter ac:name="enableSorting">false</ac:parameter>
<ac:rich-text-body>
<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></ac:structured-macro>
<h2>Return Type</h2>
<p><strong>String []</strong></p>
<p>The

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:</p><ol> <li>The

  1. The operating system exit code of the process being spawned (as string)

...

  1. The output stream (limited to 4Kb) as a

...

  1. string
  2. The error stream (limited to 4Kb) as a

...

  1. string

Example

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

Code Block
titleCreating a file using command promt
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:</p> <ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATA[string

Code Block
titleInvoking a windows .bat file
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");

...

...


Note

...

For windows operating system, you should put the full (absolute) path of the command.

...

See also

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "system_routines"
and space = currentSpace ( )</ac:parameter>
<ac:parameter ac:name="labels">array_routines</ac:parameter>
</ac:structured-macro></p>
labelssystem_routines