command execute directory
<p>i have to execute a command use python subprocess .</p>

<p>by default , command is execute as working on the directory where the python script file is . such as</p>

<pre><code> subprocess.Popen(shlex.split("ls -l"))
</code></pre>

<p>will list the file in the directory of the script file where is .</p>

<p>but i want this command to execute in another directory ,say , B .
   how can i do it .</p>

<p>i try this , but faild:</p>

<pre><code>env['PWD'] = "/data/a"
f = tempfile.TemporaryFile('w+b')
p = subprocess.Popen(shlex.split(cmd),stdout= f,stderr=f,env=env)
</code></pre>
