title: How to pass variable arguments from bash script to python script
body: <p>I've been trying to solve this issue for sometime now with no luck. The crust of the situation is that I'm using a bash script to send parameters to a a python script:</p>
  
  <p>Example:</p>
  
  <p>foo.sh calls bar.py....the call looks like: bar.py $var1 $var2 ... $varn</p>
  
  <p>The python script then prints all the arguments using the sys.argv array. The python script works correctly from the command line, but when called from with the bash script (i.e foo.sh), I get no output from bar.py.</p>
  
  <p>Also, I started foo.sh with the "#!/bin/bash -x" option and watched the output as well.</p>
  
  <p>TO summarize:</p>
  
  <ul>
  <li>Two scripts, foo.sh and bar.py</li>
  <li>foo.sh calls bar.py, passing variables of foo.sh as arguments to bar.py</li>
  <li>bar.py prints the arguments it sees using sys.argv</li>
  <li>bar.py works when run from its own terminal, doesn't work when called from foo.sh</li>
  </ul>
  
  <p>Any help would be awesome!!!!</p>
  
  <p>Thanks!</p>
  
  <p>Edit: Hi all, thanks for the replies, the complete code is pretty long...but... the contents of the two scripts could be summed</p>
  
  <p>foo.sh <strong><em>_</em>__<em>_</em></strong></p>
  
  <pre><code>#!/bin/bash
  declare -a list1;  
  declare -a list2;  
  
  list1=("foo" "bar" "please");  
  list2=("foo" "bar" "please" "help");  
  
  declare -a joined;  
  
  joined=( $(bar.py "${list1[@]}" "${list2[@]}" ) );
  </code></pre>
  
  <p>bar.py <strong><em>_</em>__<em>_</em></strong></p>
  
  <pre><code>#!/bin/python
  import sys  
  
  for arg in sys.argv:  
      print arg  
  </code></pre>
  
  <p>As I assume all the indents in the python are correct (not sure how StackOverflow does this yet :) ). These two represent the core of the issue i'm having. As stated, bar.py prints arguments correctly, when it it not called from foo.sh.  </p>
  
  <p>PS: I did mean to say "crust"  </p>