I have a Python script that requires me to set many flags. I am trying to write some shell scripts to simplify the process of executing this Python script.
I would like to have two shell scripts, params.sh and run.sh. In params.sh, I set the shell variables to the desired values like so:
VAR1=val1
VAR2=val2
...
In run.sh, I want to take the variables that I've set in params.sh, create a unique name from the values of each variable, and then use those variables as the flags to execute the Python script. So in pseudocode, what I'd like to do is
PARAMS=get_params()
UNIQUE_NAME=make_unique_name(PARAMS)
python main.py --name=$UNIQUE_NAME --VAR1=${VAR1} --VAR2=${VAR2} ...
I'm stuck on how to create a shell function that takes an arbitrary number of arguments, and how I might process the list of params to execute the Python script as it appears in the last line of pseudocode. Any suggestions would be greatly appreciated.
params.txt) and pass the path toparams.txtas the sole argument to the Python script? The Python script will then be responsible for parsingparams.txtand creating the unique name.params.shhave to actually be a shell script? Why can't it be basically the same format, but treated as a .cfg/.ini/whatever file? Then you can write a simple script (trivial in Python, for example) that reads aparams.cfgfile and prints a list of args, and allrun.shhas to do ispython main.py --name=$UNIQUE_NAME $(python parse_cfg.py params.cfg)or the like.