Odbedit: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Introduction ==  
{{Pagelinks}}
The MIDAS  <span style="color:darkcyan;">''odbedit''</span> utility  is primarily an [[Online Database (ODB)]] Editor. It also acts as a run control and has limited run monitoring features, so is an alternative to the web-based run control program [[mhttpd]]. On the other hand, <span style="color:darkcyan;">''mhttpd''</span> has limited editing capability, and does not support all of the features of <span style="color:darkcyan;">''odbedit''</span>.  
 
= Links =
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">
* [[odbedit command list]]
* [[Odbedit examples]]
* [[ODB|Using the ODB]]
* [[mhttpd]] webserver
* [[Online Database|ODB structure]]
</div>
 
= Purpose =
The MIDAS  {{Utility|name=odbedit}} utility  is primarily an [[Online Database (ODB)]] Editor. It also acts as a run control and has limited run monitoring features, so is an alternative to the web-based run control program [[mhttpd]]. On the other hand, the  {{Utility|name=mhttpd}} [[ODB Page]] is more user-friendly, but has limited editing capability and does not support all of the features of {{Utility|name=odbedit}}.  
 
= Features =
The features of {{Utility|name=odbedit}} include


The features of  <span style="color:darkcyan;">''odbedit''</span>  include
* create the ODB of the desired size
* create the ODB of the desired size
* edit/list/create/rename/re-order/delete ODB keys
* create (soft)links to ODB keys
* save all or part of the ODB onto disk and reload from a saved file
* save all or part of the ODB onto disk and reload from a saved file
* list/create/rename/re-order/delete ODB keys
* edit contents of ODB keys
* create (soft)links to ODB keys
* start/stop runs
* start/stop runs
* list and shutdown active clients
* list and shutdown active clients
* create a c-structure from the ODB  
* create a c-structure from the ODB  
* change a key's access mode (e.g. read-only)
* change a key's access mode (e.g. read-only)
* execute a list of commands from a file
* execute a list of odbedit commands from a file
* connect to corrupted ODB
* connect to corrupted ODB




<span style="color:darkcyan;">''odbedit''</span> treats the hierarchical online database very much like a file system. Most commands are similar to UNIX file commands,
{{Utility|name=odbedit}} treats the hierarchical online database very much like a file system. Most commands are similar to UNIX file commands,
e.g. ls, cd, chmod, ln etc. The help command displays a short description of all commands.
e.g. ''ls, cd, chmod, ln'' etc. The ''help'' command displays a [[Odbedit command list|short description of all commands]].


The <span style="color:darkcyan;">''odbedit''</span>  commands and mode of operation are described fully in the following sections.
The {{Utility|name=odbedit}} commands and mode of operation are described fully in the following sections.


=== Starting odbedit utility ===


Arguments
= Arguments =


     [-h hostname ] :Specifies host to connect to. See [[Common Parameters to MIDAS Utilities]]  
     [-h hostname ]     : see [[Common Parameters to MIDAS Utilities #Midas host (hostname)|common parameters]]  
     [-e exptname ] :Specifies the experiment to connect to. See [[Common Parameters to MIDAS Utilities]]  
     [-e exptname ]     : see  [[Common Parameters to MIDAS Utilities #Midas experiment (exptname)|common parameters]]  
     [-c command ] :Perform a single command
     [-c command ]     : Perform a single command. See [[#Using an external command|using an external command]]
     [-c @commandFile ] :Perform commands in sequence found in the commandFile. Can be used to perform operations in script files. See examples.
     [-c @commandFile ] : Perform commands in sequence found in the commandFile. See [[#Using an external command file|using an external command file]]
     [-s size ] : size in bytes (for ODB creation). Specify the size of the ODB file to be created when no shared file is present in the experiment directory (default 128KB).
     [-s size ]         : Size in bytes (for ODB creation). See [[#Creating the ODB|creating the ODB]].
     [-d ODB Subtree] :Specify the initial entry ODB path to go to.
     [-d ODB Subtree]   : Specify the initial entry ODB path to go to. See [[#Specifying the initial ODB entry path|Specifying the ODB entry path]].
     [-g] debug
     [-g ]             : Debug
     [-C ] connect to corrupted ODB
     [-C ]             : Connect to corrupted ODB
    [-R ]              : Reload ODB from .ODB.SHM


Notes
= Usage =
    >odbedit


* When <span style="color:darkcyan;">''odbedit''</span> is started for the first time, if there is no existing ODB for the experiment (given by the environment variable
<dl>
[[MIDAS_EXPT_NAME]] or overruled by the -e argument), the ODB will be created with the default size of 1183808 blocks.
<dt>Note</dt>
<dd> For convenience many users (including the author) make a '''symlink''' '''''odb''''' to call {{Utility|name=odbedit}}.
<pre>
cd $MIDASSYS/linux/bin
ln -s odbedit odb
</pre>
Therefore some of the examples in this document start {{Utility|name=odbedit}} with the symlink '''''odb'''''
<pre>
  >odb
</pre>
for [[#Specifying the initial ODB entry path|example here]].
</dd>
</dl>




=== odbedit command list ===
== Command Line Interpreter ==
ODBedit has a simple command line interface with command line editing similar to the UNIX tcsh shell.
The following edit keys are implemented:


Running odbedit and issuing the command "help" displays the list of commands:
[Backspace]          Erase the character left from cursor
[Delete/Ctrl-D]      Erase the character under cursor
[Ctrl-W/Ctrl-U]      Erase the current line
[Ctrl-K]            Erase the line from cursor to end
[Left arrow/Ctrl-B]  Move cursor left
[Right arrow/Ctrl-F] Move cursor right
[Home/Ctrl-A]        Move cursor to beginning of line
[End/Ctrl-E]        Move cursor to end of line
[Up arrow/Ctrl-P]    Recall previous command
[Down arrow/Ctrl-N]  Recall next command
[Ctrl-F]            Find most recent command which starts with current line
[Tab/Ctrl-I]        Complete the path. The command ls /Sy <tab> becomes ls /System.


$ odbedit
[local:pol:S]/>help


Database commands ([] are options, <> are placeholders):
==== Creating the ODB ====


alarm                  - reset all alarms
When <span style="color:darkcyan;">''odbedit''</spanis started for the first time for a Midas [[Common Parameters to MIDAS Utilities #Midas experiment (exptname)|experiment]], if there is no existing ODB for that experiment,
cd <dir>                - change current directory
the ODB will be created with the default size of 128KB, unless overruled by the  
chat                    - enter chat mode
[[odbedit #Starting odbedit utility |odbedit ''-s <size>'']] argument, e.g.
chmod <mode> <key>      - change access mode of a key
                          1=read | 2=write | 4=delete
cleanup [client] [-f]  - delete hanging clients [force]
copy <src> <dest>      - copy a subtree to a new location
create <type> <key>    - create a key of a certain type
create <type> <key>[n]  - create an array of size [n]
del/rm [-l] [-f] <key>  - delete a key and its subkeys
  -l                      follow links
  -f                      force deletion without asking
exec <key>/<cmd>       - execute shell command (stored in key) on server
  export <key> <filename> - export key into ASCII file
find <pattern>          - find a key with wildcard pattern
help/? [command]        - print this help [for a specific command]
hi [analyzer] [id]      - tell analyzer to clear histos
import <filename> [key] - import ASCII file into string key
n <source> <linkname>  - create a link to <source> key
load <file>            - load database from .ODB file at current position
ls/dir [-lhvrp] [<pat>] - show database entries which match pattern
  -l                      detailed info
  -h                      hex format
  -v                      only value
  -r                      show database entries recursively
  -p                      pause between screens
make [analyzer name]    - create experim.h
mem [-v]                - show memeory usage [verbose]
mkdir <subdir>          - make new <subdir>
move <key> [top/bottom/[n]] - move key to position in keylist
msg [type] [user] <msg> - compose user message
old [n]                - display old n messages
passwd                  - change MIDAS password
pause                  - pause current run
pwd                    - show current directory
resume                  - resume current run
rename <old> <new>      - rename key
rewind [channel]       - rewind tapes in logger
save [-c -s -x -cs] <file>  - save database at current position
                          in ASCII format
  -c                      as a C structure
  -s                      as a #define'd string
  -x                      as a XML file
set <key> <value>      - set the value of a key
set <key>[i] <value>    - set the value of index i
set <key>[*] <value>    - set the value of all indices of a key
set <key>[i..j] <value> - set the value of all indices i..j
scl [-w]                - show all active clients [with watchdog info]
shutdown <client>/all  - shutdown individual or all clients
sor                    - show open records in current subtree
start [number][now][-v] - start a run [with a specific number],
                          [now] w/o asking parameters, [-v] debug output
trunc <key> <index>    - truncate key to [index] values
ver                    - show MIDAS library version
webpasswd              - change WWW password for [[mhttpd]]
wait <key>              - wait for key to be modified
quit/exit              - exit


odbedit -s 2049000


===  Using the external command ( -c argument) ===
====  Using an external command ====


In the simplest case, a single <span style="color:darkcyan;">''odbedit''</span>  command can be entered on the command line using the ''-c'' argument, e.g.
In the simplest case, a single <span style="color:darkcyan;">''odbedit''</span>  command can be entered on the command line using the '''''-c'' argument''', e.g.


  [pol@isdaq01 src]$ odbedit -c start
  $ odbedit -c start
  Starting run #401
  Starting run #401
  Run #401 started
  Run #401 started
  [pol@isdaq01 src]$ odbedit -c stop
  $ odbedit -c stop
  Run #401 stopped
  Run #401 stopped
or
  $ odbedit -c 'set "/logger/write data" n'
  $ odbedit -c 'ls -v "/logger/write data" '
  n
This external command feature allows for sophisticated '''shell scripts''' to be created that can '''manipulate the odb'''.
See [[ODB Access and Use#Accessing the ODB from a script|accessing the ODB from a script]] for more information.


==== External command using a file ( -c &commandFile) ====
This feature can be used in various scripts - see [[ODB Access and Use#Accessing the ODB from a script]] for more information.
Perform commands in sequence found in the specified commandFile e.g.
 
==== Using an external command file ====
Perform {{Utility|name=odbedit}} commands in sequence found in the specified '''command file''' e.g.
  [pol@isdaq01 pol]$ odbedit ''-d'' /Equipment/TDC/Settings/ ''-c'' @testfile.com  
  [pol@isdaq01 pol]$ odbedit ''-d'' /Equipment/TDC/Settings/ ''-c'' @testfile.com  


where the file "testfile.com" contains odbedit commands, such as  
where the file "testfile.com" contains {{Utility|name=odbedit}} commands, such as  
  set testval 4  
  set testval 4  
  ls testval
  ls testval
  start
  start
This external command feature allows for sophisticated shell scripts to be created that can manipulate the odb.
Such scripts can for example
*    check ODB parameters prior to beginning of run
*    send run parameters to the electronic logbook
Scripts using the external command feature are often used at begin and end of run, see also
[[/Programs/execute on start run]]




===  Specifying the initial entry path (the -d argument) ===
====  Specifying the initial ODB entry path ====


The <span style="color:darkcyan;">''odbedit''</span> ''-d'' argument is used in conjunction with the ''-c'' argument to specify the initial path, e.g.
The <span style="color:darkcyan;">''odbedit''</span> ''' ''-d'' argument''' is used in conjunction with the ''' ''-c'' argument''' to specify the initial path, e.g.
  [pol@isdaq01 pol]$ odbedit -d /test -c "set testval 3"
  [pol@isdaq01 pol]$ odbedit -d /test -c "set testval 3"
  [pol@isdaq01 pol]$ odb
  [pol@isdaq01 pol]$ odb
  [local:pol:S]/>ls test
  [local:pol:S]/>ls test
  testval
  testval
==== Changing the prompt ====
The format of the <span style="color:darkcyan;">''odbedit''</span> prompt can be changed. See
[[/System ODB tree #/System/Prompt|format of the odbedit prompt]].
== [[odbedit command list]] ==
Click above link for list of odbedit commands and examples.
[[Category:Utilities]]
[[Category:ODB]][[Category:Run control]]

Latest revision as of 20:36, 27 January 2016


Links

Purpose

The MIDAS odbedit utility is primarily an Online Database (ODB) Editor. It also acts as a run control and has limited run monitoring features, so is an alternative to the web-based run control program mhttpd. On the other hand, the mhttpd ODB Page is more user-friendly, but has limited editing capability and does not support all of the features of odbedit.

Features

The features of odbedit include

  • create the ODB of the desired size
  • edit/list/create/rename/re-order/delete ODB keys
  • create (soft)links to ODB keys
  • save all or part of the ODB onto disk and reload from a saved file
  • start/stop runs
  • list and shutdown active clients
  • create a c-structure from the ODB
  • change a key's access mode (e.g. read-only)
  • execute a list of odbedit commands from a file
  • connect to corrupted ODB


odbedit treats the hierarchical online database very much like a file system. Most commands are similar to UNIX file commands, e.g. ls, cd, chmod, ln etc. The help command displays a short description of all commands.

The odbedit commands and mode of operation are described fully in the following sections.


Arguments

   [-h hostname ]     : see common parameters 
   [-e exptname ]     : see  common parameters 
   [-c command ]      : Perform a single command. See using an external command
   [-c @commandFile ] : Perform commands in sequence found in the commandFile. See using an external command file
   [-s size ]         : Size in bytes (for ODB creation). See creating the ODB.
   [-d ODB Subtree]   : Specify the initial entry ODB path to go to. See Specifying the ODB entry path.
   [-g ]              : Debug
   [-C ]              : Connect to corrupted ODB
   [-R ]              : Reload ODB from .ODB.SHM

Usage

   >odbedit
Note
For convenience many users (including the author) make a symlink odb to call odbedit.
 cd $MIDASSYS/linux/bin
 ln -s odbedit odb

Therefore some of the examples in this document start odbedit with the symlink odb

   >odb

for example here.


Command Line Interpreter

ODBedit has a simple command line interface with command line editing similar to the UNIX tcsh shell. The following edit keys are implemented:

[Backspace]          Erase the character left from cursor
[Delete/Ctrl-D]      Erase the character under cursor
[Ctrl-W/Ctrl-U]      Erase the current line
[Ctrl-K]             Erase the line from cursor to end
[Left arrow/Ctrl-B]  Move cursor left
[Right arrow/Ctrl-F] Move cursor right
[Home/Ctrl-A]        Move cursor to beginning of line
[End/Ctrl-E]         Move cursor to end of line
[Up arrow/Ctrl-P]    Recall previous command
[Down arrow/Ctrl-N]  Recall next command
[Ctrl-F]             Find most recent command which starts with current line
[Tab/Ctrl-I]         Complete the path. The command ls /Sy <tab> becomes ls /System.


Creating the ODB

When odbedit is started for the first time for a Midas experiment, if there is no existing ODB for that experiment, the ODB will be created with the default size of 128KB, unless overruled by the odbedit -s <size> argument, e.g.

odbedit -s 2049000

Using an external command

In the simplest case, a single odbedit command can be entered on the command line using the -c argument, e.g.

$ odbedit -c start
Starting run #401
Run #401 started
$ odbedit -c stop
Run #401 stopped

or

 $ odbedit -c 'set "/logger/write data" n'
 $ odbedit -c 'ls -v "/logger/write data" '
 n

This external command feature allows for sophisticated shell scripts to be created that can manipulate the odb. See accessing the ODB from a script for more information.


This feature can be used in various scripts - see ODB Access and Use#Accessing the ODB from a script for more information.

Using an external command file

Perform odbedit commands in sequence found in the specified command file e.g.

[pol@isdaq01 pol]$ odbedit -d /Equipment/TDC/Settings/ -c @testfile.com 

where the file "testfile.com" contains odbedit commands, such as

set testval 4 
ls testval
start


Specifying the initial ODB entry path

The odbedit -d argument is used in conjunction with the -c argument to specify the initial path, e.g.

[pol@isdaq01 pol]$ odbedit -d /test -c "set testval 3"
[pol@isdaq01 pol]$ odb
[local:pol:S]/>ls test
testval


Changing the prompt

The format of the odbedit prompt can be changed. See format of the odbedit prompt.

odbedit command list

Click above link for list of odbedit commands and examples.