Command Runner API
Last modified by Admin on 2024/07/05 14:38
Run a native/shell command in XWiki and get the result. |
Type | JAR |
Category | API |
Developed by | |
Active Installs | 18 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
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);
public Map<String, String> commandRunner.run(String[] executable, String standardInput, int timeoutMilliseconds);
To use:
{{velocity}}
$services.commandRunner.run('ls', '', 1000)
{{/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}}
$services.commandRunner.run([ 'ls', '-la' ], '', 1000)
{{/velocity}}
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.