subprocess call's env passing
<p>i write a python script as bellow:</p>

<pre><code>#!/usr/bin/python
import os, subprocess
env = os.environ.copy()
env['PASSWD'] = "hello jian"
retcode = subprocess.call("smbclient -L //10.60.1.11  -U Mikejian"),env=env)
print retcode
</code></pre>

<p>as i execute it , it works fine ,get retcode is 0, you know , i pass the password as an environment variable,so the python will not ask me for it .</p>

<p>it's ok 。</p>

<p>now , i want to move this code to MoinMoin's (a wiki engine) code . which in a class named User, as a function bellow</p>

<pre><code>def _validateSMBPassword(self, username, password):
    debug("call _validateSMBPassword %s:%s " % (username, password))
    import subprocess, os, shlex
    cmd = "sudo smbclient -L //%(server)s -U %(user)s"
    cmd = cmd % {
        'server' : "10.60.1.11",
        'user' : "Mikejian",
        }
    env = os.environ.copy()
    env['PASSWD'] = "hello jian"
    retcode = subprocess.call("smbclient -L //10.60.1.11  -U Mikejian",env=env,shell=True)
    debug("retcode:%d" % retcode)
    if retcode == 0:
        return True, True
    return False, False
</code></pre>

<p>in this case , i always got retcode is 1 ,not 0, it seemed that the env has not past the PASSWD environment variable.</p>

<p>could you tell me why ?and any solution suggestion?</p>
