I am trying to write a Bash script for running simulations and saving the output file in different directories. The code I have so far is:
mainDirCfg="/home/software/simplesim/simplesim-3.0/sim-outorder -config ../$1"
outFile="-redir:sim"
declare -a benchmark=("bzip2_base.i386-m32-gcc42-nn dryer.jpg" "equake_base.pisa_little <inp.in> inp.out")
declare -a directory=("bzip2" "equake")
i=0
for d in "${directory[@]}"
do
cd $d
cmdRun="$mainDirCfg $outFile $2 ${benchmark[$i]}"
# above is the command to be run
$cmdRun
cd ..
((i++))
done
The above script runs properly for the first iteration for not for the second one. However, on running the commands individually at the command prompt, I get the expected output. The command that I run for the second iteration is as follows:
/home/software/simplesim/simplesim-3.0/sim-outorder -config ../tmp.cfg -redir:sim tmp9.out equake_base.pisa_little <inp.in> inp.out
I am new to bash scripting. Can someone point out what the problem could be? Thanks.