11

I would like to pass variables to a csh script by using "qsub -v" command. I understand we can list the parameters-value pairs as below,

qsub -v par1=value1 par2=value2 myScript.csh

Does anyone know if the values of these parameters can be a string, a list of numerical numbers separated by comma sign or a filename ? for example, is the command below possible ?

qsub -v par1='Cassie_score' par2=cassieFile.txt par3='100,200,300,' myScript.csh

Thank you very much,

Cassie
  • 1,179
  • 6
  • 18
  • 30

1 Answers1

13

They just need to be comma-separated:

qsub -v var1="val1",var2=1,var3=val3 script.csh

For your example that'd be:

qsub -v par1='Cassie_score',par2=cassieFile.txt,par3='100,200,300,' myScript.csh

Just note that this wouldn't move cassieFile.txt to the node that will run the job, so cassieFile.txt would need to be a path to a location on a shared filesystem.

dbeer
  • 6,963
  • 3
  • 31
  • 47
  • 2
    If I'm not mistaken, @dbeer is the person who (basically) wrote the code that parses this option in torque >= version 4. – Jon Bringhurst Oct 19 '12 at 02:15
  • WOW~ Cool~ Thanks a lot. It worked fine with one little problem. When I set par3 as '100,200,300,', myScript.csh can only get the first value 100. I guess it assume that's the separator. Is there any way to make sure the variable par3 get the rest of string ? (The string will be used as input setting for some model running remotely so the comma separators among these 3 values can not be changed. I have no control about the format of the string.) Thank you very much, – Cassie Oct 24 '12 at 21:43
  • I eventually used space delimiter to separate the numbers in the string and add the comma back on. – Cassie Oct 30 '12 at 16:51
  • @Cassie: If you don't specify a value, the value will be copied from the environment. You can use this to get a comma-separated value through: `setenv par3 100,200,300; qsub -v par1='Cassie_score',par2=cassieFile.txt,par3 myScript.csh`. – amaurea Mar 21 '16 at 16:52