From version < 11.1 >
edited by Caleb James DeLisle
on 2015/12/02 15:34
To version < 12.1 >
edited by Caleb James DeLisle
on 2015/12/02 15:36
< >
Change comment: There is no comment for this version

Summary

Details

ExtensionCode.ExtensionClass[0]
Description
... ... @@ -4,6 +4,8 @@
4 4  Requires Programming Rights to use.
5 5  {{/warning}}
6 6  
7 +This extension allows you to run native commands on the server which is running the wiki.
8 +
7 7  API:
8 8  
9 9  {{code language=java}}
cogRun a native/shell command in XWiki and get the result
TypeJAR
Developed by

Caleb James DeLisle

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

https://raw.githubusercontent.com/xwiki-labs/xwiki-labs-logo/master/projects/xwikilabs/xwikilabsproject.png

Requires Programming Rights to use.

This extension allows you to run native commands on the server which is running the wiki.

API:

public Map<String, String> commandRunner.run(String executable, standardInput, int timeoutMilliseconds);
public Map<String, String> commandRunner.run(String[] executable, String standardInput, int timeoutMilliseconds);

To use:

{{velocity}}
$services.commandRunner.run('ls', '', 1000)
{{/velocity}}

Or if you need to support arguments with spaces and/or special characters, use the array based function signature:

{{velocity}}
$services.commandRunner.run([ 'ls', '-la' ], '', 1000)
{{/velocity}}

The bash command line application will remove quotes around process arguments automatically, so:

dostuff -axd argument "argument with spaces"

Is equivalent to:

$services.commandRunner.run([ 'dostuff', '-axd', 'argument', 'argument with spaces' ], '', 1000)

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

Get Connected