Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 如何在Slurm脚本中编写主机文件_Perl_Slurm_Sbatch - Fatal编程技术网

Perl 如何在Slurm脚本中编写主机文件

Perl 如何在Slurm脚本中编写主机文件,perl,slurm,sbatch,Perl,Slurm,Sbatch,目前我正在做以下工作 #!/bin/bash -l #SBATCH --nodes=2 #SBATCH --ntasks-per-node=4 scontrol show hostname $SLURM_JOB_NODELIST | perl -ne 'chomb; print "$_" x4' > myhostfile 这将生成以下myhostfile compute-0 compute-0 compute-0 compute-0 compute

目前我正在做以下工作

 #!/bin/bash -l
 #SBATCH --nodes=2
 #SBATCH --ntasks-per-node=4

 scontrol show hostname $SLURM_JOB_NODELIST | perl -ne 'chomb; print "$_" x4' > myhostfile
这将生成以下myhostfile

 compute-0
 compute-0
 compute-0
 compute-0
 compute-1
 compute-1
 compute-1
 compute-1
我希望得到以下结果

 compute-0
 compute-1
 compute-0
 compute-1
 compute-0
 compute-1
 compute-0
 compute-1

因此,我们可以在所有指定的节点之间进行交替

您可以这样做:

$ perl -e 'print +(<>) x 4'

您可以这样做:

$ perl -e 'print +(<>) x 4'

chomb
不是perl函数,您的意思是
chomp
?另外,
print“$”x_4
是一个语法错误,更正后语法错误。我正在使用
chomb也没有
。有
chomp
删除字符串末尾的换行符,还有
chop
删除字符串的最后一个字符。不过,这两个函数在这里都没有意义,因为您需要换行符。
chomb
不是perl函数,您是说
chomp
?另外,
print“$”x_4
是一个语法错误,更正后语法错误。我正在使用
chomb也没有
。有
chomp
删除字符串末尾的换行符,还有
chop
删除字符串的最后一个字符。不过,这两种方法在这里都没有意义,因为你想要换行符。