File: unconditional_variable_replacement.rst

package info (click to toggle)
ecflow 5.15.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,868 kB
  • sloc: cpp: 269,341; python: 22,756; sh: 3,609; perl: 770; xml: 333; f90: 204; ansic: 141; makefile: 70
file content (29 lines) | stat: -rw-r--r-- 947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.. _unconditional_variable_replacement:

Unconditional variable replacement
**********************************

The utility ~emos/bin/ls.py provides a way to dump server content below a given node. It can be used to replace a variable throughout all suites on a server:

.. code-block:: shell

    LS=~emos/bin/ls.py
    string=/vol/$USER/output
    new=/vol/${USER}_output
    
    PORT=$(($(id -n)+ 1500))
    HOST=localhost
    
    client="ecflow_client --port=$PORT --host=$HOST"
    # list all suites
    suites="$($client --suites)"
    
    # list all variables occurrence with value to change
    for s in $suites; do ECF_HOST=$HOST ECF_PORT=$PORT $LS -NRVv /$s ; done | grep $string | grep -E -v "(ECF_SCRIPT|ECF_JOB)" > list.tmp
    
    # replace
    while read -r path val;  do
        p=$(echo $path | cut -d: -f1);
        name=$(echo $path | cut -d: -f2);
        $client --alter=change variable $name $new $p;
    done < list.tmp