[Zope] Calling External Method...
Dieter Maurer
dieter@handshake.de
Mon, 22 May 2000 22:37:26 +0200 (CEST)
Eric L. Walstad writes:
> I am trying to invoke a C++ program from an external method. Platform is
> Linux. The C++ program returns HTML. Note that the Python function is
> working properly from the Python command line; That is,
> ExecCGI.xCGI("./websim") outputs all the expected html. I have placed the
> C++ program in the same folder as the ExecCGI module. The C++ program works
> from apache: here's an example of the program's output, which is what I'm
> trying to get into Zope:
>
> http://63.203.42.146/cgi-bin/websim
>
>
> ExecCGI module:
> import sys, os, string
>
> def xCGI( cmdLine ):
> """
> Run an external command and return its standard output as a string.
> """
> f = os.popen( cmdLine )
> lines = f.readlines()
> status = f.close()
> if status:
> raise "CGI returned error: %d" % status[1]
> return string.join( lines )
>
You have two problems here!
First, your program returns a non-zero exit status.
Second: "f.close()" returns a simple integer, not a sequence
that may be indexed.
Remove the "[1]" from status and you should see
the nonzero exit status.
Dieter