[Zope3-Users] execute script from as root user

James Taylor j.cole.taylor at gmail.com
Thu Jun 8 08:08:59 EDT 2006


the previous posts have covered everything necessary, but i thought
i'd say, I agree with Chris...  subprocess's Popen and PIPE make for
very simple, elegant external command access, though a knowledge of
the way popen3 works will help you understand what Popen is really
doing for you.

at a very simple level, this is what you're doing with either one
## command here already has args += with command, for convenience
## popen3
(p_in, p_out, p_err) = os.popen3(command)
p_err.read()
p_err.close()
## Popen
p = Popen(command, shell=True, close_fds=True, stderr=PIPE,
stdin=PIPE, stdout=PIPE)
error = p.stderr.read()

On 6/8/06, Chris Withers <chris at simplistix.co.uk> wrote:
> Stephan Richter wrote:
> > Use Python popen or popen3. It allows you to execute shell comands. As the
> > other response suggests, you can use "sudo" or "su" to become root.
>
> Actually, since Zope 3 uses Python 2.4, you have access to the wonderful
> subprocess module, which I'd thoroughly recommend :-)
>
> Chris
>
> --
> Simplistix - Content Management, Zope & Python Consulting
>             - http://www.simplistix.co.uk
>
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>


More information about the Zope3-users mailing list