application_osx_terminalAllows users with programming permission to run a command on the bash shell on the server
Developed by

Caleb James DeLisle

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

 Only works on a server with Linux. 

Security: None (no protection against cross site request forgery, this should be removed after use.)

This script can create processes which do not stop, it's up to you to then find and kill the processes.
{{groovy}}
if (xwiki.hasAccessLevel("programming", xcontext.getUser(), "XWiki.XWikiPreferences")) {
  String shellcmd = request.getParameter("command");
  println("{{html}}<form action='' method='POST'><input type='text' name='command' size=50 />");
  println("<input type='submit' value='Run' /></form>{{/html}}\n\n")
if (shellcmd != null ) {
    String[] cmd = ["sh", "-c", shellcmd];
    stdout = new java.io.BufferedReader(
    new java.io.InputStreamReader(Runtime.getRuntime().exec(cmd).getInputStream()));
    println("{{code language=none}}")
  while ((s = stdout.readLine()) != null) {
      println(s);
  }
    println("{{/code}}")
}
}
{{/groovy}}

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Created by Caleb James DeLisle on 2010/11/05 14:26
     

Get Connected