Converting a script to Python 3 - having trouble.

Russell Jackson rusty at rcjacksonconsulting.com
Tue Sep 15 21:21:52 EDT 2009


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 with
os.popen that they felt it needed to be thrown away, but it certainly was
MUCH easier to work with than subprocess.Popen.
I even see examples of code where people are using the communicate call, and
passing in strings, but don't have universal_newline set to true. I can't
get that to work at all without the universal_newline being set to True. The
docs on the subprocess module need a lot of enhancement in my opinion given
that is is supposed to be the replacement for all the os.popen stuff in the
prior versions.

Thanks,
Rusty

On Tue, Sep 15, 2009 at 5:11 PM, Chris Rebert <clp2 at rebertia.com> wrote:

> On Tue, Sep 15, 2009 at 5:07 PM, Chris Rebert <clp2 at rebertia.com> wrote:
> > On Tue, Sep 15, 2009 at 4:01 PM, Russell Jackson
> > <rusty at rcjacksonconsulting.com> wrote:
> > <snip>
> >> Attempted code in Python 3: (Doesn't work either)
> > <snip>
> >>         cmd = ' passwd {0}'.format(user)
> >>         pipe = Popen(p4 + cmd, shell=True, stdin=PIPE, stdout=PIPE,
> >> stderr=PIPE, universal_newlines=True)
> <snip>
>
> Scratch that, I neglected to notice the shell=True option.
>
> Cheers,
> Chris
>



-- 
Rusty

775-636-7402 Office
775-851-1982 Fax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090915/6b49a9f9/attachment-0001.html>


More information about the Python-list mailing list