sungridengine - Trying to figure out bash scripting with Sun Grid Engine -


i'm trying use integer variables within bash script submitting sun grid engine (using qsub). can clarify why not work?

numcores=32

#$ -pe mpi $numcores

(gives error "unable read script file because of error: numerical value invalid! initial portion of string "$numcores" contains no decimal number)

but does:

#$ -pe mpi 32 

i've looked @ solutions involve awk or bc can't seem make them work. new bash scripting - help!

the character # in bash script signals comments. hence, in line #$ -pe mpi $numcores, value of environement variable numcores not used, since comment.

yet, these comments useful pass parameters qsub command. see the man page , these examples instance. notice these parameters can passed on command line:

qsub -pe mpi 32 myjob.sh 

the alternative use command before qsub generate job. let's imagine job script jobgeneric.sh is:

#!/bin/bash #$ -n useless #$ -cwd #$ -pe mpi $numcores #$ -l h_vmem=6g  echo 42 

let's use sed command substitute environment variable , create new file job.sh:

export numcores=32 sed 's/$numcores/'$numcores'/g' jobgeneric.sh > job.sh cat job.sh 

see environment variable substitution in sed . result is:

#!/bin/bash #$ -n useless #$ -cwd #$ -pe mpi 32 #$ -l h_vmem=6g  echo 42 

now job can submitted using qsub job.sh!


Comments