Reputation: 245
This is the first time I am working with shell scripts. Passing one element at a time works. However I have got confused because I have a method which requires a list as an argument and currently, whatever I tried, it just takes the first element of list. But I wish to pass the entire list at one time only.
run.sh
#!/bin/bash
list = 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95;
qsub job.sh "label" $list
job.sh
#!/bin/bash
python file.py $1 $2
file.py
import sys
import os
from myClass import myClass
label = sys.argv[1]
list = sys.argv[2]
myObject = myClass(label,list)
Upvotes: 0
Views: 2011
Reputation: 207758
You need to double quote things with spaces in the shell, and drop spaces around assignments (=)
list="0.1 0.2 24 45"
qsub job.sh "label" "$list"
and
python file.py "$1" "$2"
Upvotes: 3
Reputation: 11728
Try this
job.sh
#!/bin/bash
python file.py $*
file.py
import sys
import os
from myClass import myClass
label, list = sys.argv[1], sys.argv[2:]
myObject = myClass(label, list)
Upvotes: 0