config_val_get
Updated: Sep22,2020

Read a value from a configuration file (if it is present). If the user sets the interactive flag, "-i", and the value is not present in the file (or if the file does not exist) then the user is interactively queried for the value.

 

% config_val_get  
usage: config_val_get pname [-f file ] [-i] [-h] [-s]
arg1 - name of parameter whose value is to be set 

% config_val_get --help      

EXAMPLES: 
% cat test.config 
radarcsec   2.76 
NumPixMin   8 
Sradarc     3.0 

% config_val_get boodle -i  
Enter value of boodle: 7     
% cat config_val_get.out  
 7

% config_val_get NumPixMin -f test.config   
% cat config_val_get.out  
 8

% config_val_get boot1 -f test.config   
% cat config_val_get.out  
 none


The final parameter value is by default written to the local file named "config_val_get.out", and if no value is established, then this file will contain "none". However, if the "-s" flag is set, then the value is written to standard out. This latter option makes the retrieval of parameter values within a script much more streamlined becasue it can be done with only a single line of code.


A more advanced example.

Suppose I use a routine like pasinfo or lrs2info to generata a big parameter list. I could then use config_val_get (in a single line in a script!) to quickly retrieve a given parameter value. Here is an way to do that:

 

% lrs2info 056LL all >Image.Info  

% cat Image.Info 
topbot     bot
chano      B
channel    uv
rotate     0
wavedef    /home/sco/Installs/install_sco2019_20200305/codes/fortran/gfortran_compiler/lmgf/src/critical_files/LRS2/wavesols/LL_lrs2b.solution
waveloc    ./LL_lrs2b.solution
 
% config_val_get waveloc -f Image.Info -s 
 ./LL_lrs2b.solution

In a script I might use: 
wavef=`config_val_get waveloc -f Image.Info -s` 





Back to calling page