Command Runner API

Last modified by Admin on 2021/03/19 01:31

cogRun a native/shell command in XWiki and get the result.
TypeJAR
CategoryAPI
Developed by

Caleb James DeLisle, Mohamed Boussaa

Active Installs18
Rating
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).

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.

Tags:
    

Get Connected