On Wed, 16 Sep 2009 00:01:17 +0100, Russell Jackson
<ru...@rcjacksonconsulting.com> wrote:
Hi,
I have the following code that works fine in Python 2.x, but I can't
seem to
get it to work in Python 3 with Popen. Can you please tell me how to get
the
same functionality out of Python 3? The gist of what I doing is in the
setpassword function. I have tried numerous ways to get this to work, and
just can't figure it out, and the docs on Popen are no help whatsoever on
how to use the now open process. The examples completely skip over what
to
do with the process after you open it.
So how did it fail?
###############################################################################
def setpassword(user):
password = "passworD\n"
try:
cmd = ' passwd {0}'.format(user)
pipe = Popen(p4 + cmd, shell=True, stdin=PIPE, stdout=PIPE,
stderr=PIPE, universal_newlines=True)
stderr = pipe.stdin.write(password)
time.sleep(1)
stderr = pipe.stdin.write(password)
if pipe.stdin.close != 0:
Did you perhaps mean "if pipe.stdin.close():" ?
Does it help if you read stdout rather than sleeping for arbitrary periods?
--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list