'Unable to run python script from bash scripts with string arguments

I want to run it from a bash script but it is not accepting string input with spaces. It works with single words or hyphenated words. However the python command is correct and is working fine when I am running it directly from terminal.

commands.txt

python generate.py -p "Flower girl"

jobFile.sh

#!/bin/bash

srun $(head -n $SLURM_ARRAY_TASK_ID commands.txt | tail -n 1)

exit 0

Running the bash script with :

sbatch jobFile.sh

and getting the following error: error_screenshot

I appreciate any suggestions :) Thank you!



Solution 1:[1]

This was solved by changing contents of jobFile.sh

#!/bin/bash

srun python generate.py -p "Flower girl"

exit 0

commands.txt is not required anymore.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BitastaB