I'm having an issue with a bash script I wrote yesterday that I can't figure out. I need to run a series of experiments, so I wrote this script which calls the Perl script that performs the experiment. The Perl script writes the experimental results to stdout, so I redirect that output to a file that is named individually for each experiment.
The problem is that the redirection on the `eval` line in the else block seems to be directing all output to the same file. I've tried removing the eval, and then what I believe happened is that the files captured the output from this bash script, but the output from the Perl script was nowhere to be found.
Here is the code below:
Code:
### Subroutine which runs an experiment for each
# Parameter #1: The location of the performance data to use
# Parameter #2: The location of the results set to use
# Parameter #3: The experiment name, used also in the name of the output file
perform_experiment() {
for i in `seq 1 9`
do
out_file="$out_dir/$3.${name_opts[i]}.cdf"
if [ -f $out_file ];
then
echo "WARNING: File $out_file exists! I will not overwrite it"
else
echo "$run_exe -d $1 -r $2 ${score_opts[i]} > $out_file"
eval "$run_exe -d $data_dir/ -r $results_dir/ ${score_opts[i]} > $out_file"
fi
done
}
I call this function multiple times to perform each experiment. My question is: what do I need to do to get the `eval` statement to properly re-direct the output from that invocation of the Perl script to stdout? I'm stumped.
Thanks