os.system: saving shell variables with multiple commands in one method
<p>I am having a problem using my command/commands with one instance of os.system.</p>

<p>Unfortunately I have to use os.system as I have no control over this, as I send the string to the os.system method. I know I should really use subprocess module for my case, but that ain't an option.</p>

<p>So here is what I am trying to do.</p>

<p>I have a string like below:</p>

<pre><code>cmd = "export BASE_PATH=`pwd`; export fileList=`python OutputString.py`; ./myscript --files ${fileList}; cp outputfile  $BASE_PATH/.;"
</code></pre>

<p>This command then gets sent to the os.system module like so</p>

<pre><code>os.system(cmd)
</code></pre>

<p>unfortunately when I consult my log file I get something that looks like this</p>

<pre><code>os.system(r"""export BASE_PATH=/tmp/bla/bla; export fileList=; ./myscript --files ; cp outputfile  /.;""")
</code></pre>

<p>As you can see BASE_PATH seems to be working but then when I call it with the cp outputfile  /.
I get a empty string</p>

<p>Also with my fileList I get a empty string as fileList=<code>python OutputString.py</code> should print out a file list to this variable.</p>

<p>My thoughts:</p>

<p>Are these bugs due to a new process for each command? Hence I loose the variable in BASE_PATH in the next command.</p>

<p>Also for I not sure why fileList is empty.</p>

<p>Is there a solution to my above problem using os.system and my command string?</p>

<p>Please Note I have to use os.system module. This is out of my control.</p>
