/Script ODB tree: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
(Created page with " ==== Links ==== <div style="column-count:3;-moz-column-count:3;-webkit-column-count:3"> * Online Database * mhttpd status page * ODB * </div> == Purpose == Th...")
 
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Pagelinks}}


==== Links ====
==== Links ====
Line 5: Line 5:
* [[Online Database]]
* [[Online Database]]
* [[mhttpd]] status page
* [[mhttpd]] status page
* [[#Script-button|script-button]]
* [[ODB]]
* [[ODB]]
*  
* [[/Customscript ODB tree]]
</div>
</div>


== Purpose  ==
= Purpose  =
The optional  <span style="color:purple; font-style:italic">/Script</span> 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.   
The optional  <span style="color:purple; font-style:italic">/Script</span> 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 <span style="color:purple; font-style:italic">/Script</span>  ODB tree is created 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.
 
== 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 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> (of type STRING) 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"
= Creating the <span style="color:purple; font-style:italic">/Script</span> tree =
cmd                            /home/pol/online/perl/change_mode.pl
The <span style="color:purple; font-style:italic">/Script</span> ODB tree is [[ODB#Creating ODB keys|created]] by the user. This tree is optional, and the names of any keys in this tree are chosen by the user.
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'' "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
=  <span style="color:purple; font-style:italic"><script-name></span> key or subtree =
<div id="Script-button"></div>
Any key created in the <span style="color:purple; font-style:italic">/Script</span> 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;"><script-name></span>
on the default [[mhttpd]] [[Status Page]].  


;Either
: The key can contain the name and path of the script to be executed when the script-button is pressed, e.g.
      [local:midas:S]>ls /script
      Stop Now      odbedit -c 'stop now'
      Tune X40      /home/midas/perl/tunes.sh tune X40
: In this case, two script-buttons would appear on the [[Status Page]], i.e. <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;">Stop Now</span> and <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;">Tune X40</span>,
<br>
; or
: the key may be a '''subtree''', in which case the first key in the subtree must contain the name and path of the script to be
: executed. Any further keys in the subtree contain parameters (which may include links) to be passed as arguments to the script, e.g.
      [local:midas:S]>ls "/script/change mode"
      cmd                            /home/midas/online/perl/change_mode.pl
      include path                    /home/midas/online/perl
      experiment name -> /experiment/name
                                      test_exp
      select mode -> /experiment/edit on start/select mode                   
                                      1h
      mode file tag                  none
:In this case, one script-button would be created, i.e.  <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;">change mode</span>. Pressing this button would result in the script "change_mode.pl" 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


[[Category:ODB Tree]]
[[Category:ODB Tree]]

Latest revision as of 13:05, 25 November 2016


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 the names of any keys in this tree are chosen by the user.


<script-name> key or subtree

Any key created in the /Script tree will appear as a script-button <script-name> on the default mhttpd Status Page.

Either
The key can contain the name and path of the script to be executed when the script-button is pressed, e.g.
     [local:midas:S]>ls /script
     Stop Now       odbedit -c 'stop now'
     Tune X40       /home/midas/perl/tunes.sh tune X40
In this case, two script-buttons would appear on the Status Page, i.e. Stop Now and Tune X40,


or
the key may be a subtree, in which case the first key in the subtree must contain the name and path of the script to be
executed. Any further keys in the subtree contain parameters (which may include links) to be passed as arguments to the script, e.g.
     [local:midas:S]>ls "/script/change mode"
     cmd                             /home/midas/online/perl/change_mode.pl
     include path                    /home/midas/online/perl
     experiment name -> /experiment/name
                                     test_exp
     select mode -> /experiment/edit on start/select mode                     
                                     1h
     mode file tag                   none
In this case, one script-button would be created, i.e. change mode. Pressing this button would result in the script "change_mode.pl" 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