I'm trying to edit a script of mine so that instead of only working when directly run, with whatever values are set for the variables, it can also be run via another script that queries the user as to what these variables are.
The reason I can't put this all in one is because sometimes I need to run on my university cluster and I can't read in variables in that case.
This is the relevant code from the main script:
#!/bin/bash
if [$# -eq 0]; then
echo "No input provided from control file, running with nwmag_looper values"
csv_name="testbatch_1510_Chkd"
Process="bq_tqhi_1510"
Higgs="tot"
basefilepath="/scratch/cb27g11/mg_run_basic/nw_mg_run.txt"
testfilepath="/scratch/cb27g11/mg_run_iridis/nwmag_runcard.txt"
elif [$# -eq 5]; then
echo "Input provided from control file, running with these values"
csv_name=$1
Process=$2
Higgs=$3
basefilepath=$4
testfilepath=$5
else
echo "Please provide exactly 5 inputs, csv_name, process name, higgs combination, filepath to basic MG runcard and filepath to functional MG runcard; or run directly from nwmag_looper.sh"
break
fi
So far I've just been trying to run it directly with bash nwmag_looper.sh
but unsuccessfully. It worked fine before I made the change to try and make it run both ways so I don't think there's anything wrong outside of this snippet.
I get this error
(base) [cb27g11@green0591 Looping_Bash]$ bash nwmag_looper.sh
nwmag_looper.sh: line 3: [0: command not found
nwmag_looper.sh: line 13: [0: command not found
Please provide exactly 5 inputs, csv_name, process name, higgs combination, filepath to basic MG runcard and filepath to functional MG runcard; or run directly from nwmag_looper.sh
nwmag_looper.sh: line 25: break: only meaningful in a `for', `while', or `until' loop
cut: /scratch/cb27g11/Looping_Bash/.csv: No such file or directory
data_coallator starting...
store_path is currently: /scratch/cb27g11/Data_Ripper_files/
Traceback (most recent call last):
File "/scratch/cb27g11/Data_Ripper_iridis/Data_coallator.py", line 17, in <module>
process = str(sys.argv[2])
IndexError: list index out of range
Is there something wrong with the syntax?