Project

General

Profile

Actions

Unsafe Function Module

These functions provide system level access with no safeguards. Only deploy this in an environment where you have complete control over access to the server. (We mean it!)

In order to use this module, the policy file (conf/mulgara-rmi.policy) will need to be updated. The simplest modification is to simply add execute permission to all files:

  permission java.io.FilePermission "<<ALL FILES>>", "execute";


h2. Function Description

* *mulgarax:system(string cmd)*

   Execute a command provided in the _cmd_ parameter. _cmd_ contains the complete command line, along with any required parameters. The output of the command is returned from the function as an xsd:string.

* *mulgarax:system(string cmd, string input)*

   Execute a command provided in the _cmd_ parameter, using the _input_ parameter as the input for the process (_stdin_). The output of the command is returned from the function as an xsd:string.

The format of the above commands depends on the style of operating system: Windows or *nix.

<pre>

<pre>
  prefix foaf: <http://xmlns.com/foaf/0.1/>
  prefix mulgarax: <http://mulgara.org/mulgarax#>
  select ?o ?v where {
    ?s foaf:name ?o .
    let (?v := str(mulgarax:system('/sw/bin/tr a-zA-Z A-Za-z', ?o)))
  }
</pre>

This selects names from the system, and changes case using the 'tr' command available in most *nix environments. The _str_ function is used to change from an _xsd:string_ to the more common simple literal.

<pre>
<code class="rst">
================ ================
   **o**            **v**
================ ================
"Alice Smith"    "aLICE sMITH" 
"Bob Collins"    "bOB cOLLINS" 
"Bob Smith"      "bOB sMITH" 
"Bruce Campbell" "bRUCE cAMPBELL" 
================ ================
</code></pre>

Updated by Paula Gearon over 14 years ago ยท 3 revisions