/Customscript ODB tree: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
 
= Links =
 
==== Links ====
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">
* [[Online Database]]
* [[Online Database]]
* [[mhttpd]] custom page
* [[mhttpd]]
* [[Custom Page]]
* [[/Script ODB tree]]
* [[/Script ODB tree]]
* [[ODB]]
* [[ODB]]
</div>
</div>


== Purpose  ==
= Purpose  =
The optional  <span style="color:purple; font-style:italic">/Customscript</span> ODB tree provides the user with a way to execute a script when a button on a [[mhttpd]] custom page is clicked, including the capability of passing parameters from the ODB to the user-written script. This tree is similar to the [[/Script ODB tree]].
The optional  <span style="color:purple; font-style:italic">/Customscript</span> ODB tree provides the user with a way to execute a script when a button on a [[mhttpd]] [[Custom Page]] is clicked, including the capability of passing parameters from the ODB to the user-written script. This tree is similar to the [[/Script ODB tree]].




== Creating the /Customscript tree ==
= Creating the /Customscript tree =
The <span style="color:purple; font-style:italic">/Customscript</span>  ODB tree is created by the user. This tree is optional, and apart from the tree name <span style="color:purple; font-style:italic">/Customscript</span>,  names of any keys in this tree are chosen by the user.
The <span style="color:purple; font-style:italic">/Customscript</span>  ODB tree is created by the user. This tree is optional, and apart from the tree name <span style="color:purple; font-style:italic">/Customscript</span>,  names of any keys in this tree are chosen by the user.


If the user [[ODB#Creating ODB keys|creates a new ODB tree]] named <span style="color:purple; font-style:italic">/Customscript</span> , then any key <span style="color:purple; font-style:italic">/Customscript/<button name></span> created in this tree will appear as a '''''customscript-button''''' named ''<button name>'' on a [[mhttpd]] custom page that contains suitable code - see [[Custom pages]].
<div id="Customscript-button"></div>
If the user [[ODB#Creating ODB keys|creates a new ODB tree]] named <span style="color:purple; font-style:italic">/Customscript</span> , then any key <span style="color:purple; font-style:italic">/Customscript/<button name></span> created in this tree will appear as a '''''customscript-button''''' named ''<button name>'' on a [[Custom Page]] that contains suitable code.


Each subtree  <span style="color:purple; font-style:italic">/Customscript/<button name>/</span> should contain at least one key which contains the path and name of the script. This key should be the first in the list of keys in the subtree, and will be used to execute the script when the ''customscript-button'' is pressed. Any further keys will be passed as arguments to the script. MIDAS symbolic links are permitted.
Each subtree  <span style="color:purple; font-style:italic">/Customscript/<button name>/</span> should contain at least one key which contains the path and name of the script. This key should be the first in the list of keys in the subtree, and will be used to execute the script when the ''customscript-button'' is pressed. Any further keys will be passed as arguments to the script. MIDAS symbolic links are permitted.


== Example /Customscript tree ==
= Example =


The example below shows the ODB  <span style="color:purple; font-style:italic">/Customscript/DAC</span> subtree. The presence of the <span style="color:purple; font-style:italic">DAC</span> subtree will cause the system to created a ''customscript-button'' labelled ''DAC'' on a [[mhttpd]] custom page that contains suitable code.
The example below shows the ODB  <span style="color:purple; font-style:italic">/Customscript/DAC</span> subtree. The presence of the <span style="color:purple; font-style:italic">DAC</span> subtree will cause the system to created a ''customscript-button'' labelled ''DAC'' on a [[Custom Page]] that contains suitable code.


This is identical to the [[/Script ODB tree#Example /Script tree|Example /Script tree]] except for the tree name (<span style="color:purple; font-style:italic">/Customscript</span> rather than <span style="color:purple; font-style:italic">/Script</span>).
This is identical to the [[/Script ODB tree#Example /Script tree|Example /Script tree]] except for the tree name (<span style="color:purple; font-style:italic">/Customscript</span> rather than <span style="color:purple; font-style:italic">/Script</span>).

Revision as of 18:32, 14 August 2014

Links

Purpose

The optional /Customscript ODB tree provides the user with a way to execute a script when a button on a mhttpd Custom Page is clicked, including the capability of passing parameters from the ODB to the user-written script. This tree is similar to the /Script ODB tree.


Creating the /Customscript tree

The /Customscript ODB tree is created by the user. This tree is optional, and apart from the tree name /Customscript, names of any keys in this tree are chosen by the user.

If the user creates a new ODB tree named /Customscript , then any key /Customscript/<button name> created in this tree will appear as a customscript-button named <button name> on a Custom Page that contains suitable code.

Each subtree /Customscript/<button name>/ should contain at least one key which contains the path and name of the script. This key should be the first in the list of keys in the subtree, and will be used to execute the script when the customscript-button is pressed. Any further keys will be passed as arguments to the script. MIDAS symbolic links are permitted.

Example

The example below shows the ODB /Customscript/DAC subtree. The presence of the DAC subtree will cause the system to created a customscript-button labelled DAC on a Custom Page that contains suitable code.

This is identical to the Example /Script tree except for the tree name (/Customscript rather than /Script).

The first key in the DAC subtree is the key cmd which contains the name and path of the script to be executed (in this case, a perl script). This script is located on the local host computer on which the experiment is running. The subsequent keys are parameters input to the script. The key experiment name is a soft-link to the ODB key /experiment/name.

[local:pol:R]/>ls "/customscript/DAC"
cmd                             /home/pol/online/perl/change_mode.pl
include path                    /home/pol/online/perl
experiment name -> /experiment/name
                                pol
select mode                     1h
mode file tag                   none
[local:pol:R]/>  

When the customscript-button "DAC" is pressed, the script "change_mode.pl" will be executed with the following key contents as parameters, equivalent to the command:

 /home/pol/online/perl/change_mode.pl  /home/pol/online/perl pol 1h mode