Re: Fwd: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Russell Jackson
I received a reply from the help group that suggested I added a call to flush in there, and that fixed it. The working code looks like this: def setpassword(user): password = "passworD\n" try: cmd = ' passwd {0}'.format(user) pipe = Popen(p4 + cmd, shell=True, stdin=PIPE, st

Re: Fwd: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Chris Rebert
On Tue, Sep 15, 2009 at 4:58 PM, Russell Jackson wrote: > I just get an errorlevel from the executable when I read stdout, but I can't > tell what is going on because, of course, I can't tell what Popen is > actually doing. I never see the prompt from the executable that I would > expect to see wh

Re: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Russell Jackson
Yes, I don't think the problem is that isn't running the command, I think it is just that I don't know how to communicate with it in the way that I need to in order to make this work. I have tried finding examples of working with Popen, but they are few and far between. I am not sure what was wrong

Re: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Chris Rebert
On Tue, Sep 15, 2009 at 5:07 PM, Chris Rebert wrote: > On Tue, Sep 15, 2009 at 4:01 PM, Russell Jackson > wrote: > >> Attempted code in Python 3: (Doesn't work either) > >>         cmd = ' passwd {0}'.format(user) >>         pipe = Popen(p4 + cmd, shell=True, stdin=PIPE, stdout=PIPE, >> stderr=

Re: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Chris Rebert
On Tue, Sep 15, 2009 at 4:01 PM, Russell Jackson wrote: > Attempted code in Python 3: (Doesn't work either) >         cmd = ' passwd {0}'.format(user) >         pipe = Popen(p4 + cmd, shell=True, stdin=PIPE, stdout=PIPE, > stderr=PIPE, universal_newlines=True) You're not specifying the command

Re: Fwd: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Russell Jackson
I just get an errorlevel from the executable when I read stdout, but I can't tell what is going on because, of course, I can't tell what Popen is actually doing. I never see the prompt from the executable that I would expect to see when I read stdout. I originally had the function like this: def s

Re: Fwd: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Rhodri James
On Wed, 16 Sep 2009 00:01:17 +0100, Russell Jackson 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

Fwd: Converting a script to Python 3 - having trouble.

2009-09-15 Thread Russell Jackson
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,