pass variable script argument to another script then pass to program
After reading through numerous bash script threads and help sites, I
cannot find a solution that works.
I want to pass a variable argument 'i' from a script to another script $i,
then pass this to a program "$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.
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.
So far I have read topic on:
"-C option" Passing arguments to /bin/bash via a bash script
"pass arguments"
http://linux.about.com/od/Bash_Scripting_Solutions/a/How-To-Pass-Arguments-To-A-Bash-Script.htm
"start with argument $0 or #1" How can I pass a file argument to my bash
script using a Terminal command in Linux?
"pass arguments"
http://how-to.wikia.com/wiki/How_to_read_command_line_arguments_in_a_bash_script
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; 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
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. I do not know if the prescript correctly passes
variable i to the script. 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.
No comments:
Post a Comment