[Zope] External script question
Jerome Alet
alet@librelogiciel.com
Mon, 24 Jun 2002 20:34:02 +0200
On Mon, Jun 24, 2002 at 02:18:36PM -0400, Kevin Carlson wrote:
>
> It is a rather long involved script, but here is the piece that is failing.
> I am trying to integrate with mailman and create a new list by using the
> following script:
>
> nlcommand = "/home/mailman/bin/newlist -q test test@test.org test"
>
> if(os.system(nlCommand)) :
> retval = "newlist command failed."
> return retval
IMHO you should carefully check the os.system() call's return value.
you could replace the os.system() call with the following one
which I know for sure works :
def myexec(commandline) :
import popen2
process = popen2.Popen3(commandline, capturestderr=1)
retcode = process.wait()
output = process.fromchild.read()
errors = process.childerr.read()
and check retcode according to the W* functions in
http://www.python.org/doc/current/lib/os-process.html#os-process
of course depending on the retcode you may or may not have
to read the child's stdout or stderr.
hth.
Jerome Alet