简体   繁体   English

将变量脚本参数传递给另一个脚本,然后将qsub传递给程序

[英]pass variable script argument to another script then qsub to program

After reading through numerous bash script threads and help sites, I cannot find a solution that works. 在阅读了许多bash脚本线程和帮助站点之后,我找不到有效的解决方案。

I want to pass a variable argument 'i' from a script to another script $i, then qsub this to a program "$1". 我想将变量参数“ i”从一个脚本传递到另一个脚本$ i,然后将其qsub传递给程序“ $ 1”。 In the program I read the variable from the argument vector (**argv) and then use this variable to modify the name of output files as *_0, *_1, *_2, ..., *_n. 在程序中,我从参数向量(** argv)中读取了变量,然后使用此变量将输出文件的名称修改为* _0,* _ 1,* _ 2,...,* _ n。

The idea is so I can have a unique output file for each instance of a program. 这样的想法是,我可以为程序的每个实例提供一个唯一的输出文件。 The program is parallel but due to limitations of the computing resources, I need to submit one job for a maximum of four computing nodes - or it will never pass through the que. 该程序是并行的,但是由于计算资源的限制,我需要为最多四个计算节点提交一份作业-否则它将永远无法通过队列。 So, I'd like to spin off 64 4-node jobs. 因此,我想分拆64个4节点作业。

So far I have read topic on: 到目前为止,我已经阅读了以下主题:

After reading these, I feel comfortable with the concept but still it is confusing how exactly the -C and -S command are used, or if they are used at all; 阅读这些内容后,我对这个概念感到满意,但是仍然使-C和-S命令的使用方式以及是否完全使用它们感到困惑。 most examples exclude these. 大多数示例都排除了这些。

This is my spinoff pre-script 这是我的附带要求

#
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1
for((i=0; i < 2; i++)); do qsub test_S17_script.sh $i; done

side info: what is qsub 附带信息: 什么是qsub

And this is my script 这是我的剧本

#
#$ -M duser@acme_u.edu
#$ -m bae
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1

./daedalus_linux_1.3_64 1 "$1"

So, the spinoff works fine, and generates the files. 因此,分拆工作正常,并生成文件。 And, the script works fine passing a constant ./daedalus_linux_1.3_64 1 1 but passing the variable does not work. 并且,通过传递常量./daedalus_linux_1.3_64 1 1的脚本可以正常工作,但传递变量无效。 I do not know if the prescript correctly passes variable i to the script. 我不知道该处方是否正确将变量i传递给了该脚本。 I don't know how to write to a error file from a script - or if this is even how I want to check if the variable is passed. 我不知道如何从脚本中写入错误文件-甚至这就是我要检查变量是否通过的方式。 The computing has no user interface so once it is in the queue I must rely on error file outputs. 计算没有用户界面,因此一旦进入队列,我就必须依靠错误文件输出。

Thank you in advance for your help. 预先感谢您的帮助。

If you're looking to pass standard output from your prescript to the script, you could do something like: 如果您希望将标准输出从您的规范传递到脚本,则可以执行以下操作:

./daedalus_linux_1.3_64 1 `<prescript>`

If the prescript prints output from each iteration of the for loop (i=0, i=1) on separate lines, you could probably pipe the output generated by your prescript to the xargs command. 如果该规定在单独的行上打印for循环(i = 0,i = 1)的每个迭代的输出,则可能可以将规定产生的输出通过管道传递给xargs命令。

In the prescript, you could change the output formatting to display all output generated by each iteration of qsub on a single line as follows: 在规定中,您可以更改输出格式,以在一行上显示qsub每次迭代生成的所有输出,如下所示:

for((i=0; i < 2; i++)); do qsub test_S17_script.sh $i; done | xargs

or you can use xargs as follows: 或者您可以如下使用xargs:

./daedalus_linux_1.3_64 1 `<prescript> | xargs`

Hope that helps. 希望能有所帮助。

Consider using PBS Job Arrays . 考虑使用PBS Job Arrays A single pbs script will submit multiple jobs and each job will have a different value for the environment variable $PBS_ARRAY_INDEX. 单个pbs脚本将提交多个作业,并且每个作业的环境变量$ PBS_ARRAY_INDEX具有不同的值。

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

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