简体   繁体   English

无法使用字符串 arguments 从 bash 脚本运行 python 脚本

[英]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.我想从 bash 脚本运行它,但它不接受带空格的字符串输入。 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.但是 python 命令是正确的,当我直接从终端运行它时工作正常。

commands.txt命令.txt

python generate.py -p "Flower girl"

jobFile.sh作业文件.sh

#!/bin/bash

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

exit 0

Running the bash script with:使用以下命令运行 bash 脚本:

sbatch jobFile.sh

and getting the following error: error_screenshot并收到以下错误: error_screenshot

I appreciate any suggestions:) Thank you!我感谢任何建议:) 谢谢!

This was solved by changing contents of jobFile.sh这是通过更改jobFile.sh的内容解决的

#!/bin/bash

srun python generate.py -p "Flower girl"

exit 0

commands.txt is not required anymore.不再需要 commands.txt。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM