title: pass variable script argument to another script then qsub to program
body: <p>After reading through numerous bash script threads and help sites, I cannot find a solution that works.</p>
  
  <p>I want to pass a variable argument 'i' from a script to another script $i, then qsub 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. </p>
  
  <p>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.</p>
  
  <p>So far I have read topic on:</p>
  
  <ul>
  <li>"-C option" <a href="https://stackoverflow.com/questions/12059528/passing-arguments-to-bin-bash-via-a-bash-script">Passing arguments to /bin/bash via a bash script</a></li>
  <li>"pass arguments"
  <a href="http://linux.about.com/od/Bash_Scripting_Solutions/a/How-To-Pass-Arguments-To-A-Bash-Script.htm" rel="nofollow noreferrer">http://linux.about.com/od/Bash_Scripting_Solutions/a/How-To-Pass-Arguments-To-A-Bash-Script.htm</a> </li>
  <li>"start with argument $0 or #1"
  <a href="https://stackoverflow.com/questions/3534280/how-can-i-pass-a-file-argument-to-my-bash-script-using-a-terminal-command-in-lin">How can I pass a file argument to my bash script using a Terminal command in Linux?</a></li>
  <li>"pass arguments"
  <a href="http://how-to.wikia.com/wiki/How_to_read_command_line_arguments_in_a_bash_script" rel="nofollow noreferrer">http://how-to.wikia.com/wiki/How_to_read_command_line_arguments_in_a_bash_script</a></li>
  <li>the exact same question I am asking but the answers don't really work for my case <a href="https://stackoverflow.com/questions/11354186/using-a-loop-variable-in-a-bash-script-to-pass-different-command-line-args?lq=1">Using a loop variable in a bash script to pass different command-line args</a></li>
  </ul>
  
  <p>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.</p>
  
  <p>This is my spinoff pre-script</p>
  
  <pre><code>#
  #$ -cwd
  #$ -S /bin/bash
  #$ -pe fah 1
  for((i=0; i &lt; 2; i++)); do qsub test_S17_script.sh $i; done
  </code></pre>
  
  <p>side info: <a href="http://wiki.ibest.uidaho.edu/index.php/Tutorial:_Submitting_a_job_using_qsub#What_is_qsub.3F" rel="nofollow noreferrer">what is qsub</a></p>
  
  <p>And this is my script</p>
  
  <pre><code>#
  #$ -M duser@acme_u.edu
  #$ -m bae
  #$ -cwd
  #$ -S /bin/bash
  #$ -pe fah 1
  
  ./daedalus_linux_1.3_64 1 "$1"
  </code></pre>
  
  <p>So, the spinoff works fine, and generates the files. And, the script works fine passing a constant <code>./daedalus_linux_1.3_64 1 1</code> 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.</p>
  
  <p>Thank you in advance for your help.</p>