/Script ODB tree: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
* [[Online Database]]
* [[Online Database]]
* [[mhttpd]] status page
* [[mhttpd]] status page
* [[#Script-button|script-button]]
* [[ODB]]
* [[ODB]]
* [[/Customscript ODB tree]]
* [[/Customscript ODB tree]]
Line 15: Line 16:
The <span style="color:purple; font-style:italic">/Script</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">/Script</span>,  names of any keys in this tree are chosen by the user.
The <span style="color:purple; font-style:italic">/Script</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">/Script</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">/Script</span> , then any key <span style="color:purple; font-style:italic">/Script/<button name></span> created in this tree will appear as a '''''script-button''''' named ''<button name>'' on the default [[mhttpd]] status page. Each subtree  <span style="color:purple; font-style:italic">/Script/<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 ''script-button'' is pressed. Any further keys will be passed as arguments to the script. MIDAS symbolic links are permitted.
<div id="Script-button"></div>
If the user [[ODB#Creating ODB keys|creates a new ODB tree]] named <span style="color:purple; font-style:italic">/Script</span> , then any key <span style="color:purple; font-style:italic">/Script/<button-name></span> created in this tree will appear as a '''''script-button''''' <span style="color: #444444; background-color: #CCCCCC; font-style:italic; font-size: 90; padding:0.25em;padding-left: 0.5em;padding-right: 0.5em;border:1px solid #808080;border-radius: 5px;margin-bottom:1px;"><button-name></span>
on the default [[mhttpd]] status page.  
<br>Each subtree  <span style="color:purple; font-style:italic">/Script/<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 ''script-button'' is pressed. Any further keys will be passed as arguments to the script. MIDAS symbolic links are permitted.


== Example /Script tree ==
== Example /Script tree ==


The example below shows the ODB  <span style="color:purple; font-style:italic">/Script/DAC</span> subtree. The presence of the <span style="color:purple; font-style:italic">DAC</span> subtree will cause the system to created a ''script-button'' labelled ''DAC'' on the [[mhttpd]] status page.
The example below shows the ODB  <span style="color:purple; font-style:italic">/Script/cmode</span> subtree. The presence of the <span style="color:purple; font-style:italic">cmode</span> subtree will cause the system to created a ''script-button''  
<span style="color: #444444; background-color: #CCCCCC; font-style:italic; font-size: 90; padding:0.25em;padding-left: 0.5em;padding-right: 0.5em;border:1px solid #808080;border-radius: 5px;margin-bottom:1px;">cmode</span> on the [[mhttpd]] status page.


The first key in the <span style="color:purple; font-style:italic">DAC</span> subtree is the key <span style="color:purple; font-style:italic">cmd</span> 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 <span style="color:purple; font-style:italic">experiment name</span> is a soft-link to the ODB key  <span style="color:purple; font-style:italic">/experiment/name</span>.
The first key in the <span style="color:purple; font-style:italic">cmode</span> subtree is the key <span style="color:purple; font-style:italic">cmd</span> 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 <span style="color:purple; font-style:italic">experiment name</span> is a soft-link to the ODB key  <span style="color:purple; font-style:italic">/experiment/name</span>.


  [local:pol:R]/>ls "/script/DAC"
  [local:pol:R]/>ls "/script/cmode"
  cmd                            /home/pol/online/perl/change_mode.pl
  cmd                            /home/pol/online/perl/change_mode.pl
  include path                    /home/pol/online/perl
  include path                    /home/pol/online/perl
Line 32: Line 37:
  [local:pol:R]/>   
  [local:pol:R]/>   


When the ''script-button'' "DAC" is pressed, the script "change_mode.pl" will be executed with the following key contents as parameters, equivalent to the command:
When the ''script-button'' <span style="color: #444444; background-color: #CCCCCC; font-style:italic; font-size: 90; padding:0.25em;padding-left: 0.5em;padding-right: 0.5em;border:1px solid #808080;border-radius: 5px;margin-bottom:1px;">cmode</span> 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
   /home/pol/online/perl/change_mode.pl  /home/pol/online/perl pol 1h mode

Revision as of 16:35, 5 August 2014


Links

Purpose

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

Creating the /Script tree

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

If the user creates a new ODB tree named /Script , then any key /Script/<button-name> created in this tree will appear as a script-button <button-name> on the default mhttpd status page.
Each subtree /Script/<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 script-button is pressed. Any further keys will be passed as arguments to the script. MIDAS symbolic links are permitted.

Example /Script tree

The example below shows the ODB /Script/cmode subtree. The presence of the cmode subtree will cause the system to created a script-button cmode on the mhttpd status page.

The first key in the cmode 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 "/script/cmode"
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 script-button cmode 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