Rewrite file with hardcoded variables in UNIX SHell -
i have properties file (mydataflow.properties) called upon argument (--override) in unix shell script - see below.
source ./myshell.properties $dr_home/bin/dr -cp $cp_plugin -xmx64g --engine parallelism=1 --runjson $workflow_dir/mydataflow.dr --overridefile mydataflow.properties >> $log_file
unfortunately program being called upon here must have variables in properties file hardcoded. able use variables "myshell.properties" file or environment variables within "mydataflow.properties" file, can move script new environments.
for example mydataflow.properties file sets following variable:
dataflow.url=jdbc:ingres://someserver01.local:vw7/mydb
however use variable called "mydburl" read in myshell.properties instead mydataflow.properties file this:
dataflow.url=$mydburl
as cannot around fact dataflow.url variable must hardcoded, looking way read mydataflow.properties file non hardcoded variables, , write out new file have hardcoded variables - set using myshell.properties file. call upon new file when trying run mydataflow.dr.
i hope makes sense. or pointers hugely appreciated.
thanks,
paul.
so idea read mydataflow.properties line line, make replacements, , write out replaced line. right?
let's assume shell variable current_line
holds 1 original line property file expanded. use
eval 'echo $current_line' >>hardcodeddataflow.properties
this solution applies sh/bash/ksh. if happy running shell script under zsh, can simpler:
echo ${(e)current_line} >>hardcodeddataflow.properties
Comments
Post a Comment