Same code cause the different result.

叶佑群 ye.youqun at eisoo.com
Wed Apr 25 02:51:13 EDT 2012


Hi, all

    I have code as:

/            pobj = subprocess.Popen (["smbpasswd", user], stdin 
=subprocess.PIPE)
             password += "\n"
             pobj.stdin.write (password)
             pobj.stdin.write (password)/

     the command smbpasswd will change the samba user's password, In 
shell this will run as below:

/            [root at localhost ~]# smbpasswd mytest1
             New SMB password:
             Retype new SMB password:
             [root at localhost ~]# /

     but in python code, it always prompt to wait input the password, it 
is seems that pobj.stdin.write () doesn't work. It is anything wrong 
with my code? I have another block code that runs as expected:

/            pobj = subprocess.Popen (["passwd", user], stdin = 
subprocess.PIPE)
             password = password + "\n"
             pobj.stdin.write (password)
             pobj.stdin.write (password)/

     It is so curious and I wonder why.It is the same result when 
substitute smbpasswd with pdbedit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120425/03b8f845/attachment.html>


More information about the Python-list mailing list