The context here is a Beowulf HPC cluster. I will simplify the code:
for img in $images; do
script=$(mktemp)
cat > $script <<EOF ######## What does this line do?
module load mymodule
my_processing -with $img
EOF
# cat $script
# qsub $script
done
The script can be printed to screen to verify all paths have been resolved correctly by uncommenting the cat $script line, and similarly submitted as a job by uncommenting the qsub $script line. I have basic understanding of the > operator, but to my understanding it is cating nothing into the $script... Obviously that's not what's really happening because this all works.