title: How to access python return value from bash script
body: <p>I'm trying to understand how to access from a bash script the return value of a python script. </p>
  
  <p>Clarifying through an example:</p>
  
  <p><strong>foo.py</strong></p>
  
  <pre><code>def main():
      print ("exec main..")
      return "execution ok"
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p><strong>start.sh</strong></p>
  
  <pre><code>script_output=$(python foo.py 2&gt;&amp;1)
  echo $script_output
  </code></pre>
  
  <p>If I run the bash script, this prints the message "exec main..".</p>
  
  <p>How can I store in <em>script_output</em> the return value (<em>execution ok</em>)? 
  If I direct <em>execution ok</em> to stdout, the script_output will capture all the stdout (so the 2 print statement).</p>
  
  <p>Is there any way to implement this?</p>
  
  <p>Thanks!
  Alessio</p>