叶佑群 wrote:
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@localhost ~]# smbpasswd mytest1
New SMB password:
Retype new SMB password:
[root@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.
I'm totally *not* an expert in those kind of things but I remember
someone saying that sometimes, and especialy when asking for password,
unix program do not use stdin.
However, it looks like you can use an command line option to change the
password:
http://lists.samba.org/archive/samba/2004-August/091019.html
Cheers,
JM
--
http://mail.python.org/mailman/listinfo/python-list