Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>sys.exit(myString)</code> doesn't mean "return this string". If you pass a string to <a href="http://docs.python.org/library/sys.html#sys.exit" rel="nofollow noreferrer"><code>sys.exit</code></a>, <code>sys.exit</code> will consider that string to be an error message, and it will write that string to <code>stderr</code>. The closest concept to a return value for an entire program is its <a href="https://en.wikipedia.org/wiki/Exit_status" rel="nofollow noreferrer">exit status</a>, which must be an integer.</p> <p>If you want to capture output written to stderr, <a href="https://stackoverflow.com/questions/3130375/bash-script-store-stderr-in-variable">you can do something like</a> </p> <pre><code>python yourscript 2&gt; return_file </code></pre> <p>You could do something like that in your bash script</p> <pre><code>output=$((your command here) 2&gt; &amp;1) </code></pre> <p>This is not guaranteed to capture only the value passed to <code>sys.exit</code>, though. Anything else written to stderr will also be captured, which might include logging output or stack traces.</p> <p>example:</p> <p>test.py</p> <pre><code>print "something" exit('ohoh') </code></pre> <p>t.sh</p> <pre><code>va=$(python test.py 2&gt;&amp;1) mkdir $va </code></pre> <p><code>bash t.sh</code></p> <p><em>edit</em></p> <p>Not sure why but in that case, I would write a main script and two other scripts... Mixing python and bash is pointless unless you really need to.</p> <pre><code>import script1 import script2 if __name__ == '__main__': filename = script1.run(sys.args) script2.run(filename) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload